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 ?
#3
ok... the appending part seems to be working now...
I have modified the code a bit....


def fizz_buzz_advanced(db,ll,ul):
    ndb = {}
    for i in range(ll,ul):
        for k,v in db.items():
            p = i%k
            if (p == 0):
                ndb[i] = v
            else:
                n = ''
                ndb[i] = n
    print ndb

db = {3:'Fizz', 5:'Buzz'}
ll = 2
ul = 7
fizz_buzz_advanced(db,ll,ul)
but am not getting the desired output now...
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