Oct-11-2021, 03:56 AM
Hello all,
I have a function which checks if an entry is a number or not. The code works fine on my pc which is running python 3.7.9 (bottom right had corner of Thonny). However, on my raspberry pi this code doesn't work. My raspberry pi is running python 3.7.3. For some reason sudo apt-get upgrade python3 didn't upgrade my pi to the same version as my PC.
Regardless, on my Pi when i try float("not a numebr") it returns an error, so i would assume that try function would work even despite the lower version number of python. Any thoughts?
I have a function which checks if an entry is a number or not. The code works fine on my pc which is running python 3.7.9 (bottom right had corner of Thonny). However, on my raspberry pi this code doesn't work. My raspberry pi is running python 3.7.3. For some reason sudo apt-get upgrade python3 didn't upgrade my pi to the same version as my PC.
Regardless, on my Pi when i try float("not a numebr") it returns an error, so i would assume that try function would work even despite the lower version number of python. Any thoughts?
def isNumber(argument): try: float(argument) prnit("Is number") return 1 except: print("not a number") return 0 num = "777" float(num) print(isNumber(num))