Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- shopping = [] # Let's create an empty list variable
- how_many = input("How many items of shopping are needed? ")
- how_many = int(how_many)
- for item_number in range(how_many): # Let's add a "for" loop with a range to loop x times
- item = input("What is item number " + str(item_number) + "? ") #
- shopping.append(item) # Let's append item to the list
- print(shopping) # After the "for" loop let’s print the list
- for item in shopping:
- print(item)
- len(shopping)
- result = str(len(shopping))# Function "len"
- print ("I have " + result + " items in my shopping account") # Let's show a total at the end
- # Another way to show a total at the end
- print "The items in my shopping account are",len (shopping)
- count = 0
- for item in shopping:
- print(item)
- count = count + 1 # Counter
- print(count)
Add Comment
Please, Sign In to add comment