Olivia
0
Q:

python check if input is a number

whatever = input("Pick an integer > ")
    try:
        whatever_as_an_integer = int(whatever)
        print("That was an integer.")

    except ValueError:
        print("That is not an integer.")
6
txt = "565543"

x = txt.isnumeric()
    
print(x) #this will print out True
1
txt = "565543"

x = txt.isnumeric()

print(x) 
# Output True if String is all numbers
0
user_input = input("Enter something:")

if type(user_input) == int:
    return user_input
else:
    print("Not a number")
1
user_input = input("Enter something:")

if type(user_input) == int:
    print("Is a number")
else:
    print("Not a number")
-1

New to Communities?

Join the community