Python shopping cart program 🛒

preview_player
Показать описание
#python #tutorial #course

# Shopping cart exercise

foods = []
prices = []
total = 0

while True:
food = input("Enter a food to buy (q to quit): ")
break
else:
price = float(input(f"Enter the price of a {food}: $"))

print("----- YOUR CART -----")

for food in foods:
print(food, end=" ")

for price in prices:
total += price

print()
print(f"Your total is: ${total}")
Рекомендации по теме
Комментарии
Автор

# Shopping cart exercise

foods = []
prices = []
total = 0

while True:
food = input("Enter a food to buy (q to quit): ")
if food.lower() == "q":
break
else:
price = float(input(f"Enter the price of a {food}: $"))
foods.append(food)
prices.append(price)

YOUR CART

for food in foods:
print(food, end=" ")

for price in prices:
total += price

print()
print(f"Your total is: ${total}")

BroCodez
Автор

BROOO you are the best i just started learning pyhton and i couldnt get shit how the teacher explained stuff than i started to watch your vidyia and holy shit you explain it so well and easy to understand.

apathy
Автор

Really like those, keel them going buddy!

bashar
Автор

Nice exercise for beginners, great work

skyisthelimpet
Автор

Napaka simple ng explanation at madaling maintindihan. Salamat!

PonderP
Автор

I had so much fun with my shopping cart list program😁

tara
Автор

You are the best bro code, i hope you see this!

corexx
Автор

good work! Let's try write this program on C# )

iqlmogv
Автор

That exercise was great! Can you do some more advanced coding Technics?

eyalsilbershtein
Автор

how do you declare a list? ive atempted to make something similar to this but my lists are getting the undeclared error

Beeposky
Автор

i think a line of code where you can only enter string for items and float for price would be good

tennybabcock
Автор

What's the purpose of the f in the beginning on the string?

spacenstuff
Автор

can you come up with a program or project connecting python with any database like mysql ...

FactlessFact-ByRaji
Автор

Please could you do PHP beginner full course? Your videos are like an oasis in the desert for people like us who have financial struggles. Thanks a million BRO!!!

nicolewynne
Автор

How you enjoy the Dracula theme in pycharn?

programmercat
Автор

Can you make a video how to create round button in java pls😢

setok
Автор

Can you make a video with a coffe shop?

BelleMosa
Автор

what if the user enter letter not number in price? HOW WE CAN FIXIT

aissaboukrikeb
Автор

Surprisingly, I am getting an " unsupported operand type(s) for +: int and list" error. Here is my code
foods = []
prices = []
total = 0

while True:
food = input(" Enter a food to buy('q' to quit): ")
if food.lower() == "q":
break
else:
price = float(input(f"Enter the price of a {food}: Kshs "))
foods.append(food)
prices.append(prices)

print Cart
for food in foods:
print (food, end= ' ')

for price in prices:
total += price

print(f"Your total is Kshs{total}")

What could be wrong here?

mwaijames
Автор

My computer us saying that append cannot be used when float is present something like that so i used teh add is it correct ?

ufc_dhruv