I am writing a program that needs to check if a users input is a decimal (the users input must be a deciamal number),I was wondering how I could test a varible to see if it contains only a decimal number.
Thanks, Jarvey
U also could use a Try/Except to check if the variable is an integer:
try:
val = int(userInput)
except ValueError:
print("That's not an int!")
or a float:
try:
val = float(userInput)
except ValueError:
print("That's not an float!")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With