Python Forum
how do i add new items to a dictionary ?
Thread Rating:
  • 2 Vote(s) - 2.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
how do i add new items to a dictionary ?
#4
ndb[i] = v is where your problem lies.  Your output always has Buzz in the right places, but you never see Fizz.  That's because you always compare Fizz first, set it where it needs to be, and then compare for Buzz and overwrite whatever you did for Fizz.

One possible solution would be to do ndb[i] = "" before you iterate over the db, and then when a match is found, you simply add it to whatever was already there with += .
Reply


Messages In This Thread
RE: datastructures... - by micseydel - Dec-08-2016, 06:41 PM
RE: datastructures... - by roadrage - Dec-08-2016, 07:13 PM
RE: datastructures... - by nilamo - Dec-08-2016, 07:30 PM

Forum Jump:

User Panel Messages

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