Here's something nobody tells you at the start: every program you write is going to break.
Not might. Will. That doesn't change with experience — people who write Python for a living break things constantly. They've just got quick at reading what came back.
When Python hits something it genuinely cannot do, it stops and prints a wall of red text. That wall looks like you're in trouble. You aren't. It's a report, and it's trying to hand you the answer.