Oct-11-2021, 04:51 AM
I would expect
One problem you have is that you are catching all errors with the
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
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.
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.