2

just need a little help. Starting out doing python, trying to create a high score program and I want to say while score is not equal to an integer then ask user to input score.

For example (this doesn't work)

name = input("Please enter your name: ")
score = None
while score != int(score):
    score = input("Enter your score: ")
print("congratz it worked genius")

thanks in advance

4

1 回答 1

5
 while True:
    try:
        score = int(input("Enter your score: "))
        break
    except ValueError:
        print("Int, please.")
于 2013-11-14T17:32:16.163 回答