Using A Loop To Add Objects To A List(python)
I'm trying to use a while loop to add objects to a list. Here's basically what I want to do: class x: pass choice = raw_input(pick what you want to do) while(choice!=0):
Solution 1:
The problem appears to be that you are reinitializing the list to an empty list in each iteration:
whilechoice!=0:...a= []
a.append(s)
Try moving the initialization above the loop so that it is executed only once.
a= []
whilechoice!=0:...a.append(s)
Post a Comment for "Using A Loop To Add Objects To A List(python)"