I need to write a short code that the user can input prices from a shopping trip and when the user input 0 the while loop will stop. After it stops I need to have an else statement to show the total number of items, average price, and total price. I am new to programming and I am starting off in python. Please let me know what I am doing wrong.
price = float
items = float
while price < 0:
items = price
price = input("Please enter prices of items:")
else:
avg = float(sum(items) / len(items))
print('Number of items purchased:', len(items))
print('Average price of items: $', avg)
print('Total price of purchased items: $', sum(items))
while price < 0: TypeError: '<' not supported between instances of 'type' and 'int'
Aucun commentaire:
Enregistrer un commentaire