Bottom Page

Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 My exception doesn't work. How can I correct it?
#1
>>> try:
    print(1 / 0)
    except ArithmeticError:
        
SyntaxError: invalid syntax
>>>
Quote
#2
What you are trying to accomplish?
"As they say in Mexico 'dosvidaniya'. That makes two vidaniyas."
https://freedns.afraid.org
Quote
#3
You need to provide a body for the except branch. You can use the pass keyword if you want to ignore the excepetion.
Quote
#4
You have to indent back if you are using IDLE,it dos not do it automatically for you.
>>> try:
       print(1 / 0)
except ArithmeticError:
    print('Can not divide by 0')

Can not divide by 0
>>>
hsunteik and micseydel like this post
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Not quite getting the correct Output from a function twinpiques 3 146 Aug-04-2019, 11:53 PM
Last Post: twinpiques
  read text file and write into html with correct link jacklee26 4 146 Aug-02-2019, 05:48 AM
Last Post: jacklee26
  Asyncio StreamReader read method doesn't respect timeout when using SSL dukadahake 0 72 Jul-24-2019, 11:55 AM
Last Post: dukadahake
  Pynput doesn't recognize shift button and special characters VirtualDreamer 0 93 Jul-17-2019, 11:55 AM
Last Post: VirtualDreamer
  How to fix 'uncaught exception of type NSException' in Python MonsterPython 0 111 Jul-09-2019, 06:52 AM
Last Post: MonsterPython
  problem using custom exception handling in python srm 3 172 Jul-03-2019, 09:10 PM
Last Post: ichabod801
  'Exception Has occured: UnBoundLocalError' caston 1 161 Jun-12-2019, 02:33 PM
Last Post: perfringo
  Why doesn't my loop work correctly? (problem with a break statement) steckinreinhart619 2 246 Jun-11-2019, 10:02 AM
Last Post: steckinreinhart619
  Help with finding correct topic in Python learning yahya01 1 276 Jun-06-2019, 05:01 PM
Last Post: buran
  an easy way to disable exception handling Skaperen 6 413 Jun-02-2019, 10:38 PM
Last Post: Gribouillis

Forum Jump:


Users browsing this thread: 1 Guest(s)