我的if语句不起作用:
choice = float(input("Enter 1 to enter sec. Enter 2 to enter mins")):
#My problem:
if 'choice' == 1
a = float(input("Enter secs"))
等...
顺便说一句,我正在做一个计时器,但我需要知道...它告诉我语法无效...
答案 0 :(得分:0)
固定代码(带有我的评论):
choice = int(raw_input("Enter 1 to enter sec. Enter 2 to enter mins")) # no need to use float here, also in python2 please use raw_input
if choice == 1: # you tried to compare `choice` string with 1 (always False), compare choice variable value with 1 instead. Also note, that you missed : after if
a = float(input("Enter secs"))
答案 1 :(得分:0)
我知道了!
choice + int(input("Bla bla bla")):
我忘记了':'