I have the last part partially done I just need help with it

I have the last part partially done. I just need help with it ending when they type done. Here\'s what I have so far, although the end stuff might not be accurate:

fruit_names = []
fruit_prices = []
names = []

fruit = raw_input(\"Enter a fruit name (or done): \")
while not (fruit == \"done\"):
fruit_names += [fruit]
fruit = raw_input(\"Enter a fruit name (or done): \")

for s in fruit_names:
price = float(raw_input(\"Enter the price for \" + s + \": \"))
fruit_prices += [price]

name = raw_input(\"Enter customer name (or done): \")

while not (name == \"done\"):
names += [name]
name = raw_input(\"Enter customer name (or done): \")
total_price = 0
for i in range(len(fruit_names)):
    quantity = int(raw_input(fruit_names[i] + \"($\" + str(fruit_prices[i]) + \") Quantity: \"))
    total_price += quantity * fruit_prices[i]
print(name + \"\'s total purchase is $\" + str(total_price))

Here are the directions and the example:

Continue the fruit_stand.py program. It should prompt the vendor for customer names, and then for each customer calculate the total. The program should only stop once the vendor types \"done\" for a customer name.

The following is an example. Your program must first prompt the vendor for the fruit names and prices (see parts 1, 2) before prompting for customer names and fruit quantities.

Enter a fruit name (or done): Mango

Enter a fruit name (or done): Apple
Enter a fruit name (or done): Kiwi
Enter a fruit name (or done): done

Enter the price for Mango: 2.54
Enter the price for Apple: 0.23
Enter the price for Kiwi: .75

Enter customer name (or done): Hilda
Mango($2.54) Quantity: 3
Apple($0.23) Quantity: 10
Kiwi($0.75) Quantity: 2

Hilda\'s total purchase is $11.42

Enter customer name (or done): Jim
Mango($2.54) Quantity: 10
Apple($0.23) Quantity: 40
Kiwi($0.75) Quantity: 20

Jim\'s total purchase is $49.6

Enter customer name (or done): Bob
Mango($2.54) Quantity: 0
Apple($0.23) Quantity: 0
Kiwi($0.75) Quantity: 1

Bob\'s total purchase is $0.75

Enter customer name (or done): done

Please give me some help on ending it when I type in done as it\'s not working.

Solution

fruit_names = []
fruit_prices = []
names = []

fruit = raw_input(\"Enter a fruit name (or done): \")
while (fruit != \"done\"):
fruit_names += fruit
fruit = raw_input(\"Enter a fruit name (or done): \")

for s in fruit_names:
price = float(raw_input(\"Enter the price for \" + s + \": \"))
fruit_prices += price

name = raw_input(\"Enter customer name (or done): \")

while (name != \"done\"):
names += name
total_price = 0
for i in range(len(fruit_names)):
quantity = int(raw_input(fruit_names[i] + \"($\" + str(fruit_prices[i]) + \") Quantity: \"))
total_price += quantity * fruit_prices[i]
print(name + \"\'s total purchase is $\" + str(total_price))

name = raw_input(\"\ Enter customer name (or done): \")

I have the last part partially done. I just need help with it ending when they type done. Here\'s what I have so far, although the end stuff might not be accura
I have the last part partially done. I just need help with it ending when they type done. Here\'s what I have so far, although the end stuff might not be accura

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site