+ 1

Practice: Coffee Time

Hello, I do not understand why this code is not working. Could anyone just give a hint to me please. def coffee(): choices=int(input()) 1=Americano 2=Espresso 3=Cappuccino if choices ==1: print("Americano") elif choices ==2: print("Espresso") elif choices ==3: print("Cappuccino") else: print("Unknown")

15th Feb 2023, 9:59 PM
Denis Durban
Denis Durban - avatar
7 odpowiedzi
17th Feb 2023, 6:21 PM
Lothar
Lothar - avatar
+ 4
2 things Denis Durban 1 your code appears to have no indentations which python sees as blocks and the second or no. 2 is how or where did you call the function coffee() def coffee(c): blocks of your if elif(s) else here ... c = int(nput()) coffee(c)
15th Feb 2023, 10:05 PM
BroFar
BroFar - avatar
+ 3
BroFar Thank you. I fixed it and the code is working now.
15th Feb 2023, 10:49 PM
Denis Durban
Denis Durban - avatar
+ 1
Great ☺
15th Feb 2023, 11:57 PM
BroFar
BroFar - avatar
+ 1
def coffee(): drinks = ["Americano", "Espresso", "Cappuccino"] choice = int(input()) if choice == 1: print(drinks[0]) elif choice == 2: print(drinks[1]) elif choice == 3: print(drinks[2]) else: print("Unknown")
17th Feb 2023, 11:35 AM
VSYZ
VSYZ - avatar
+ 1
coffe=int(input()) for i in range(1,3+1): if coffe==1: print("americano") elif coffe ==2: print("espresson") elif coffe==3: print("cappuccion") else:print("unknown") Done
17th Feb 2023, 4:40 PM
CoderAj
+ 1
Lothar What about now sir ? Was in hurry and left fixing indentations for problem presenter Try it now sir .....Thank U for ur point. https://code.sololearn.com/c7Y7VfaqLTkL/?ref=app
18th Feb 2023, 12:19 PM
CoderAj