title: In Python, how do I create a new variable each time a loop goes around, and then send them all to a function to be processed?
body: <p>I'm still relatively new to python, and this is probably way out of my ability, but I'm working on a program (For a school programming course) that asks for a new item, the price of that item, and the quantity of that item each time a loop goes around. (The loop will be stopped by typing stop when the program asks if there are more items to process) The program will then sends all those variables to a module I created that will calculate the total cost of each item based on the quantity, and then print out the cost of each item, and the total cost.</p>
  
  <p>My teacher says this is possible, but he doesn't quite know how to do it.</p>
  
  <p>Here's what I have so far (I tried to use a list, but it doesn't seem to be working out):</p>
  
  <p>First Program (total_run.py):</p>
  
  <pre><code>import total_cost
  
  itemname = []
  itemprice = []
  quantity = []
  
  stop = "go"
  
  while stop != "stop":
      itemname.append(input("What is the name of the item?\n"))
      itemprice.append(float(input("What is the price of the item?\n")))
      quantity.append(float(input("How many of these items are there?\n")))
      stop = input("Enter \"stop\" to add up the total")
  
  
  name,price = total_cost.total(itemname,itemprice,quantity)
  
  totalprice = total_cost.final(itemprice)
  
  #Not sure how to print an unknown number of times
  print(name,"    $",price)
  print("Your total is: $", totalprice)
  </code></pre>
  
  <p>Second Program (total_cost.py):</p>
  
  <pre><code>#Calculates all the costs
  
  itemprice = 0
  
  def total(itemname,itemprice,quant):
      itemprice = 0
      itemname = itemname
      for values in quant:
      itemprice *= values
  
  
      return itemname,itemprice
  
  def final(itemprice):
      finalcost = itemprice += itemprice
      #I'm not sure on how to add up all the items in a list
      return finalcost      
  </code></pre>