我的if语句不起作用:
choice = float(input("Enter 1 to enter sec. Enter 2 to enter mins"))
#My problem:
if 'choice' == 1
a = float(input("Enter secs"))
等...
顺便说一句,我正在做一个计时器,但我需要知道...它告诉我语法无效...
固定代码(带有我的评论):
choice = int(input("Enter 1 to enter sec. Enter 2 to enter mins")) # no need to use float here
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"))