Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
updating a dictionary
#3
(Feb-19-2020, 09:43 PM)evansmb Wrote: I'm trying to enter several key/value pairs in a dictionary, however it appears each update overwrites the previous addition.

Yes, this is the core feature of Python dictionary:

Quote:It is best to think of a dictionary as a set of key: value pairs, with the requirement that the keys are unique (within one dictionary).
/../
If you store using a key that is already in use, the old value associated with that key is forgotten.
I'm not 'in'-sane. Indeed, I am so far 'out' of sane that you appear a tiny blip on the distant coast of sanity. Bucky Katt, Get Fuzzy

Da Bishop: There's a dead bishop on the landing. I don't know who keeps bringing them in here. ....but society is to blame.
Reply


Messages In This Thread
updating a dictionary - by evansmb - Feb-19-2020, 09:43 PM
RE: updating a dictionary - by Larz60+ - Feb-19-2020, 11:55 PM
RE: updating a dictionary - by perfringo - Feb-20-2020, 10:08 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Updating dictionary with tuple Mark17 2 2,109 Aug-06-2020, 02:59 PM
Last Post: Mark17
  Updating dictionary values Sukumar 2 2,524 Oct-03-2018, 09:53 PM
Last Post: Sukumar

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020