Python Forum
try function working on PC but not raspberry pi
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
try function working on PC but not raspberry pi
#1
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?
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))
Reply


Messages In This Thread
try function working on PC but not raspberry pi - by AnotherSam - Oct-11-2021, 03:56 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Excel isnt working properly after python function is started IchNar 2 409 May-01-2024, 06:43 PM
Last Post: IchNar
Shocked kindly support with this dropna function not working gheevarpaulosejobs 2 781 Jul-24-2023, 03:41 PM
Last Post: deanhystad
Exclamation Function Not Working Alivegamer 7 1,999 Jul-19-2022, 01:03 PM
Last Post: deanhystad
  Input() function not working in VS Code darpInd 7 13,676 Feb-17-2020, 03:28 PM
Last Post: snippsat
  Unrelated new function causing existing working function to fail Nick_G 2 2,336 Jan-27-2020, 07:21 PM
Last Post: Nick_G
  User Defined function not working Raj_Kumar 4 3,107 Dec-17-2019, 12:44 PM
Last Post: buran
  Function not working eglaud 0 1,688 Oct-24-2019, 03:30 PM
Last Post: eglaud
  Invoking function in if else statement, not working! ibaad1406 13 5,839 May-30-2019, 09:05 PM
Last Post: ibaad1406
  function not working tryingtolearnpython 2 3,034 Jul-23-2018, 02:54 AM
Last Post: tryingtolearnpython
  function for SQLite query not working pythonNoob 1 2,867 May-16-2018, 05:21 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020