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")
Run Code Online (Sandbox Code Playgroud)
thanks in advance
while True:
try:
score = int(input("Enter your score: "))
break
except ValueError:
print("Int, please.")
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
7787 次 |
| 最近记录: |