Feb-23-2021, 09:17 PM
I created the following dictionary and added another key:value.
Is there a way to "add" the element where I want? Second, can the last key:value be moved?
Here is the desired outcome:
Dave
>>> super_hero_names = { ... 'Superman' : 'Clark Kent', ... 'Spiderman' : 'Peter Parker' ... } >>> >>> batman = {'Batman' : 'Bruce'} >>> super_hero_names.update(batman) >>> super_hero_names {'Superman': 'Clark Kent', 'Spiderman': 'Peter Parker', 'Batman': 'Bruce'} >>> super_hero_names.update(Batman = "Bruce Wayne") >>> super_hero_names {'Superman': 'Clark Kent', 'Spiderman': 'Peter Parker', 'Batman': 'Bruce Wayne'}How do I move 'Batman': 'Bruce Wayne' as the first in the dictionary so the outcome would make the last key:value the first?
Is there a way to "add" the element where I want? Second, can the last key:value be moved?
Here is the desired outcome:
>>> super_hero_names {'Batman': 'Bruce Wayne','Superman': 'Clark Kent', 'Spiderman': 'Peter Parker'}Best,
Dave