Other Errors

suggest change

AssertError

The assert statement exists in almost every programming language. When you do:

assert condition

or:

assert condition, message

It’s equivalent to this:

if __debug__:
    if not condition: raise AssertionError(message)

Assertions can include an optional message, and you can disable them when you’re done debugging.

Note: the built-in variable debug is True under normal circumstances, False when optimization is requested (command line option -O). Assignments to debug are illegal. The value for the built-in variable is determined when the interpreter starts.

KeyboardInterrupt

Error raised when the user presses the interrupt key, normally Ctrl + C or del.

ZeroDivisionError

You tried to calculate 1/0 which is undefined. See this example to find the divisors of a number:

div = float(raw_input("Divisors of: "))
for x in xrange(div+1): #includes the number itself and zero
    if div/x == div//x:
        print x, "is a divisor of", div
div = int(input("Divisors of: "))
for x in range(div+1): #includes the number itself and zero
    if div/x == div//x:
        print(x, "is a divisor of", div)

It raises ZeroDivisionError because the for loop assigns that value to x. Instead it should be:

div = float(raw_input("Divisors of: "))
for x in xrange(1,div+1): #includes the number itself but not zero
    if div/x == div//x:
        print x, "is a divisor of", div
div = int(input("Divisors of: "))
for x in range(1,div+1): #includes the number itself but not zero
    if div/x == div//x:
        print(x, "is a divisor of", div)

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:


Common Exceptions:
* Other Errors

Table Of Contents
2 Filter
3 List
7 Loops
22 Reduce
27 Classes
31 Set
42 Tuple
45 Enum
62 Sockets
89 urllib
92 Idioms
104 Stack
105 Profiling
109 Logging
111 os module
118 Mixins
120 ArcPy
126 Arrays
132 2to3 tool
135 Unicode
138 Neo4j
140 Curses
141 Templates
145 heapq
146 tkinter
154 Audio
155 pyglet
157 ijson
160 Flask
161 Groupby
163 pygame
165 hashlib
166 Gzip
167 ctypes
171 Common Exceptions
185 pyaudio
186 shelve