Skip to content Skip to sidebar Skip to footer

Python: Checking Whether Or Not A Variable Is A Int (using While Loop)

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

Solution 1:

 while True:
    try:
        score = int(input("Enter your score: "))
        break
    except ValueError:
        print("Int, please.")

Post a Comment for "Python: Checking Whether Or Not A Variable Is A Int (using While Loop)"