I am trying to make a program which so i can put in orders and have shopping and handling calculated the problem is, each time i run the program there will be a different number of people placing an order, how would i set up a loop that on each cycle creates a new variables? example:

loopController = input("how many order did we have today? ")
while loopController >= 0:
    name = raw_input("Who's order")
    order = input("How much was the order")
    orderTotal = order + shippingCharge
    loopController = loopController - 1

after all loops are completed i would like to be able to print out a list of each person and their corresponding order total

any help would be greatly appreciated.

Re: creating new variables each time a loop is run 80 80

Something like this.

name = []
ordertotal = []
for i in range(loopController):
    name.append(raw_input("Who's order"))
    order = input("How much was the order")
    ordertotal.append(order + shippingCharge)

for i in range(loopController):
    print name[i], ordertotal[i]
Re: creating new variables each time a loop is run 80 80

Another option would be to create a list of (name, order_total) tuples. This way you can sort the list by name or find a person that ordered several times ...

# a simple purchase order program

shipping = 4.95
order_number = int(raw_input("How many orders today: "))

order_list = []
for k in range(order_number):
    name = raw_input("Enter name: ")
    value = float(raw_input("Enter value of order: "))
    order_total = value + shipping
    order_list.append((name, order_total))

# test

for customer, total in order_list:
    print("%-20s    $%5.2f" % (customer, total))

""" possible result >>>
How many orders today: 3
Enter name: Mike Marthner
Enter value of order: 99.05
Enter name: Abby Arthritis
Enter value of order: 123.55
Enter name: Tadt Target
Enter value of order: 45.01
Mike Marthner           $104.00
Abby Arthritis          $128.50
Tadt Target             $49.96
Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.19 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.