只需要一点帮助。开始做python,试图创建一个高分程序,我想说当分数不等于整数然后要求用户输入分数。
例如(这不起作用)
name = input("Please enter your name: ")
score = None
while score != int(score):
score = input("Enter your score: ")
print("congratz it worked genius")
提前致谢
答案 0 :(得分:4)
while True:
try:
score = int(input("Enter your score: "))
break
except ValueError:
print("Int, please.")