Common Python Errors¶

  • AttributeError
    • AttributeError: XXX object has no attribute YYY
  • FileNotFoundError
    • FileNotFoundError: [Errno 2] No such file or directory: XXX
  • ImportError
    • ImportError: No module named XXX
  • IndentationError
    • IndentationError: expected an indented block
    • IndentationError: unexpected indent
    • IndentationError: unindent does not match any outer indentation level
  • IndexError
    • IndexError: XXX index out of range
  • KeyError
    • KeyError: XXX
  • NameError
    • NameError: name XXX is not defined
  • SyntaxError
    • SyntaxError: invalid syntax
    • SyntaxError: EOL while scanning string literal
    • SyntaxError: EOF while scanning triple-quoted string literal
  • TypeError
    • TypeError: Can’t convert XXX object to str implicitly
    • TypeError: unorderable types: XXX > YYY
    • TypeError: can only concatenate XXX (not YYY) to XXX
    • TypeError: XXX indices must be integers, not YYY
    • TypeError: unsupported operand type(s) for XXX: YYY and ZZZ
    • TypeError: bad operand type for unary XXX: YYY
    • TypeError: XXX object is not subscriptable
    • TypeError: XXX missing YYY required positional argument: ZZZ
    • TypeError: XXX object cannot be interpreted as an YYY
    • TypeError: unhashable type: XXX
  • UnboundLocalError
    • UnboundLocalError: local variable xxx referenced before assignment
  • ValueError
    • ValueError: could not convert XXX to YYY: ZZZ
    • ValueError: invalid literal for int() with base 10: XXX
    • ValueError: math domain error

Logo

Programming Course

Quick search

©2025, Prof. Lluís Vila, dept. CS, ETEIB, UPC. Publicat sota la llicència Reconeixement-CompartirIgual 3.0 No adaptada de Creative Commons. | Powered by Sphinx 5.3.0 & Alabaster 0.7.12 | Page source
This page uses Google Analytics to collect statistics. You can disable it by blocking the JavaScript coming from www.google-analytics.com.