How do you add input from user into list in Python

pythonswag picture pythonswag · Jan 10, 2014 · Viewed 151.5k times · Source
print ('This is your Shopping List')          
firstItem = input('Enter 1st item: ')         
print (firstItem)             
secondItem = input('Enter 2nd item: ')           
print (secondItem)  

How do I make a list of what the user has said then print it out at the end when they have finished?

Also how do I ask if they have added enough items to the list? And if they say no then it will print out the list of items already stored.

Thanks, I'm new to this so I don't really know.

Answer

Oni1 picture Oni1 · Jan 10, 2014
shopList = [] 
maxLengthList = 6
while len(shopList) < maxLengthList:
    item = input("Enter your Item to the List: ")
    shopList.append(item)
    print shopList
print "That's your Shopping List"
print shopList