0
В чем ошибка
coffee = ["Café Latte", "Caffe Americano", "Espresso", "Cappuccino", "Macchiato"] choice = int(input()) if choice => 1 and =< 5: print(coffee[choice]) else: print(choice + "error")
14 Antworten
+ 3
Try to do
print(choice, " error")
or
print("{0} error".format(choice))
or
print(str(choice)+" error")
all of this should work but you only need one
+ 1
You need to start from 0 and end at 4 becouse indexes start from 0
if 0<=choice and choice <=4
+ 1
If you want to start form 1 you need to need to change print(coffe[choice]) after if to
print(coffe[choice-1])
or change choice var to
choice = int(input())-1
+ 1
Use same datatypes
0
If choice >= 1 and choice <= 5:
You forgot about choice after and and you placed => and =< instead of >= and <=
0
А как мне заставить код начинать отчет не с нуля а с 1?
0
Нет все равно и с if 1<= choice <= 5: не работает
0
How i can input start 1 but indexes start 0. I mean simebody write 1, programm print " Caffe Latte" on 0
0
Ou yes you right. Its workin. 1<= choise <= 5 just need delete? Its dont needed for code?
0
It's needed becouse if needs some condition (eg. soms values to compare)
0
Ok but why dont workin end code
coffee = ["Café Latte", "Caffe Americano", "Espresso", "Cappuccino", "Macchiato"]
choice = int(input())
if 1<= choice <= 5:
print(coffee[choice-1])
else:
print(choice + "error")
Print(choice + "error") dont working. I should delet choice and finally they write error. But I want his write for exemple "7 error"
0
Yes thank its work)))) now i know little more)) thanks
0
Короче, старый добрый повтор:
if choice=>1 and choice=<5:
0
А разве так писать нельзя?