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.
Feel like you're not getting the answers you want? Checkout the help/rules for things like what to include/not include in a post, how to use code tags, how to ask smart questions, and more.

Pro-tip - there's an inverse correlation between the number of lines of code posted and my enthusiasm for helping with a question :)
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
>>>
micseydel and hsunteik like this post
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  why my function doesn't work cimerio 3 114 Nov-20-2019, 01:13 PM
Last Post: ChislaineWijdeven
  For loop in my __init__ doesn't work as expected Jessy 2 100 Nov-18-2019, 10:07 AM
Last Post: buran
  Python: command “python -m pip install --upgrade pip” doesn't work apollo 2 279 Sep-16-2019, 03:11 PM
Last Post: snippsat
  Why doesn't my loop work correctly? (problem with a break statement) steckinreinhart619 2 370 Jun-11-2019, 10:02 AM
Last Post: steckinreinhart619
  Python Code doesn't work! the_entrepreneur 5 480 Apr-20-2019, 08:05 AM
Last Post: SheeppOSU
  New to MySQL, can't work out why code doesn't work kintarowonders 6 567 Feb-18-2019, 05:23 PM
Last Post: kintarowonders
  This doesn't work like in book Blaedel 1 383 Jan-14-2019, 05:41 PM
Last Post: metulburr
  Why doesn't strip work? cybervigilante 5 768 Dec-27-2018, 02:21 AM
Last Post: metulburr
  During handling of the above exception, another exception occurred Skaperen 7 7,191 Dec-21-2018, 10:58 AM
Last Post: Gribouillis
  Caesar Cypher--- I don't understand why it doesn't work ironsheep 12 1,098 Nov-03-2018, 06:53 PM
Last Post: j.crater

Forum Jump:


Users browsing this thread: 1 Guest(s)