I have built my program and the only way I can get it to actually calculate the input is by inputting a break. I need the whole program to repeat without using break and without being infinite.
I have already tried to use break and duplicated the entire program structure but I would rather only do the structure one time.
ask_again = 'yes'
while ask_again == 'yes':
item1 = float(input('Enter a value for item 1: '))
item2 = float(input('Enter a value for item 2: '))
item3 = float(input('Enter a value for item 3: '))
total_cost = (item1 + item2 + item3)
average_cost = (total_cost / 3)
print("The total cost is", "$", format(total_cost, '.2f'))
print("The average cost is", "$", format(average_cost, '.2f'))
ask_again = input("Do you want to do another purchase? Enter 'yes' to
continue or 'no' to end: ")
I expect the output to be total cost and average cost repeated based upon users continue input
Aucun commentaire:
Enregistrer un commentaire