Advertisement
elena_gancedo

Create_list

Jun 25th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.65 KB | None | 0 0
  1. bill = []  # Create an empty list variable
  2. how_many = input("How many things in your bill do you have? ")
  3. how_many = int(how_many)
  4. for thing_number in range(how_many): # Add a for loop with a range to loop x times
  5.       thing = input("What is the thing number " + str(thing_number) + "? ") #Include each thing_number in the corresponding prompts to the user for bill things.
  6.       bill.append(thing) # Append the thing to the list.
  7. print(bill) # After the for loop print the list.      
  8. print "The things in the bill list : ",len (bill) # Function "len".
  9. count = 0
  10. for thing in bill:
  11.     print(thing)
  12.     count = count + 1 # Counter
  13.     print(count)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement