Mack's LoL Scout
Explain

Tracebacks (how to read the scary wall of text)

A traceback is Python showing you exactly where it got confused. You don’t need to “understand all of it”. You need three parts.

TL;DR (read from the bottom)

  • The last line is the error type + message.
  • The line above it usually points at the code that triggered it.
  • Fix one thing, rerun, repeat.

Common beginner errors (and what they mean)

IndentationError

Python uses indentation as syntax. Mixed spaces/tabs or missing indents.

Looks like

IndentationError: expected an indented block

KeyError

You asked a dict for a key that doesn’t exist.

Looks like

KeyError: 'info'

TypeError

You used the wrong type (like treating a list as a dict).

Looks like

TypeError: list indices must be integers or slices, not str

FileNotFoundError

Usually: you ran the program from the wrong folder.

Looks like

FileNotFoundError: [Errno 2] No such file or directory

The “ask for one fact” trick

When you’re stuck, print the smallest fact that tells you what you have: type, length, keys.

High-signal prints

print(type(x))
print(len(x))
print(list(x.keys())[:10])