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
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
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,
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'
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