Let's see an example. The following dictionary has a couple of keys, protocol and size, and I want to change the "protocol" key to "inet_protocol", and in addition, preserve its content.
>>> my_dict = {"protocol": "HTTP", "size": 1024} >>> my_dict["inet_protocol"] = my_dict.pop("protocol") >>> >>> print my_dict {'inet_protocol': 'HTTP', 'size': 1024}
Python-dictionary tutorial for beginners Free Learn By CodeExampler
ReplyDeleteC# for Loop Statement Learn Free for Beginners by CodeExampler website
ReplyDelete