Use a while loop to collect a shopping list of items from the user. Then use a while or for loop to list it back to them.

i have:

item = int(input('How many items do you have? '))
        while item  > 0:
            input('Name of item:  ')
            item -= 1

i don't know how to change this into a list, or repeat it with a loop

You use a Python list object this way ...

number_item = int(input('How many items do you have? '))

mylist = []  # start with an empty list
count = 1
while number_item  > 0:
    item = input('{}) Name of item:  '.format(count))
    mylist.append(item)
    number_item -= 1
    count += 1

# test
print(mylist)

''' possible result ...
How many items do you have? 3
1) Name of item:  hot dogs
2) Name of item:  buns
3) Name of item:  mustard
['hot dogs', 'buns', 'mustard']
'''

Edited 3 Years Ago by vegaseat

Once you have the list, you can show its contents this simple way ...

# show list items to customer
print("You ordered:")
mylist = ['hot dogs', 'buns', 'mustard']
for item in mylist:
    print(item)

''' result ...
You ordered:
hot dogs
buns
mustard
'''

Edited 3 Years Ago by vegaseat

This question has already been answered. Start a new discussion instead.