Re: [Tutor] Adding key, value to Dictionary

2009-03-27 Thread Emile van Sebille
David wrote: greg whittier wrote: On Fri, Mar 27, 2009 at 1:31 PM, David wrote: But I can not get this to update after the first time it is ran. def get_todo(): Other common ways this is done include: def get_todo(todo={}): ... This works well if one copy is to be used the entire time

Re: [Tutor] Adding key, value to Dictionary

2009-03-27 Thread David
greg whittier wrote: On Fri, Mar 27, 2009 at 1:31 PM, David wrote: But I can not get this to update after the first time it is ran. def get_todo(): todo = {} moved todo{} outside of the function This set todo to an empty dictionary each time you execute get_todo. Ok I see it now. to

Re: [Tutor] Adding key, value to Dictionary

2009-03-27 Thread David
David wrote: I am trying to make a simple Todo program and I can not get the dictionary to update. This works; #!/usr/bin/python key = 'Clean house' value = (1,2,3,4) todo = {key:value} value = (5,6,7,8) todo['Walk Dog'] = value print todo results {'Walk Dog': (5, 6, 7, 8), 'Clean house': (1,

Re: [Tutor] Adding key, value to Dictionary

2009-03-27 Thread greg whittier
On Fri, Mar 27, 2009 at 1:31 PM, David wrote: > But I can not get this to update after the first time it is ran. > > def get_todo(): >    todo = {} This set todo to an empty dictionary each time you execute get_todo. >    key = raw_input('Enter Todo Title: ') >    todo[key] = key >    print '\n'

[Tutor] Adding key, value to Dictionary

2009-03-27 Thread David
I am trying to make a simple Todo program and I can not get the dictionary to update. This works; #!/usr/bin/python key = 'Clean house' value = (1,2,3,4) todo = {key:value} value = (5,6,7,8) todo['Walk Dog'] = value print todo results {'Walk Dog': (5, 6, 7, 8), 'Clean house': (1, 2, 3, 4)} OK g