Working with dictionaries and keys help please!
David D
daviddschool at gmail.com
Wed May 31 20:29:55 EDT 2017
I have a dictionary with a 10 people, the key being a number (0-10) and the value being the people's name. I am in the processing of Insert, Adding and deleting from the dictionary. All seems well until I delete a person and add a new one. The numbers (keys) do not change and so I am getting an non-sequential set of numbers for the keys. Is there a way of performing this where the key will update so that is continues to work sequentially? Here is what I mean
Print dictionary
{0 John, 1 David, 2 Phil, 3 Bob}
remove 1 David
{0 John, 2 Phil, 3 Bob}
How can I get it so that the VALUE will reset and it will look like this after both adding or deleting?
{0 John, 1 Phil, 2 Bob}
More information about the Python-list
mailing list