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
#2
I would expect float("not a numebr") to return an error for any version of python (a ValueError exception).

One problem you have is that you are catching all errors with the except: on line 6. You should instead catch only the ValueError thrown by the float that you might expect.

This causes a problem because line 4 has a typo (prnit instead of print). That syntax error it caught by line 6 and assumed to be a problem with the float. You don't print any information about the error.

Fix your typo and change the except line to except ValueError:

There's no difference here with your python version. I assume that you don't have an exact copy and only one of them has the typo in it.
Underscore likes this post
Reply


Messages In This Thread
RE: try function working on PC but not raspberry pi - by bowlofred - Oct-11-2021, 04:51 AM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Excel isnt working properly after python function is started IchNar 2 417 May-01-2024, 06:43 PM
Last Post: IchNar
Shocked kindly support with this dropna function not working gheevarpaulosejobs 2 789 Jul-24-2023, 03:41 PM
Last Post: deanhystad
Exclamation Function Not Working Alivegamer 7 2,009 Jul-19-2022, 01:03 PM
Last Post: deanhystad
  Input() function not working in VS Code darpInd 7 13,714 Feb-17-2020, 03:28 PM
Last Post: snippsat
  Unrelated new function causing existing working function to fail Nick_G 2 2,338 Jan-27-2020, 07:21 PM
Last Post: Nick_G
  User Defined function not working Raj_Kumar 4 3,115 Dec-17-2019, 12:44 PM
Last Post: buran
  Function not working eglaud 0 1,689 Oct-24-2019, 03:30 PM
Last Post: eglaud
  Invoking function in if else statement, not working! ibaad1406 13 5,845 May-30-2019, 09:05 PM
Last Post: ibaad1406
  function not working tryingtolearnpython 2 3,040 Jul-23-2018, 02:54 AM
Last Post: tryingtolearnpython
  function for SQLite query not working pythonNoob 1 2,870 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