Skip to content

Latest commit

 

History

History
57 lines (40 loc) · 1.51 KB

File metadata and controls

57 lines (40 loc) · 1.51 KB

Troubleshooting Guide

Python/Thonny Issues

"SyntaxError: invalid syntax"

Cause: Missing colon, quote, or parenthesis Fix: Check line mentioned in error for:

  • Colons after if/while/for/def
  • Matching quotes ("text" not "text)
  • Matching parentheses

"NameError: name 'x' is not defined"

Cause: Using variable before creating it Fix: Define variable before using: x = 0

"IndentationError"

Cause: Wrong spaces/tabs Fix: Use Thonny's auto-indent (Tab key)

Program runs but nothing happens

Cause: No output or waiting for input Fix: Add print() statements or check for input() calls


Pygame Zero Issues

"ModuleNotFoundError: No module named 'pgzero'"

Fix: Install in Thonny: Tools → Manage Packages → pgzero

Window opens and closes immediately

Fix: Make sure you have draw() function defined

"NameError: name 'screen' is not defined"

Fix: Don't run as regular Python - use pgzrun or add import pgzrun; pgzrun.go()


micro:bit Issues

micro:bit not showing as drive

Fix: Try different USB cable (some are charge-only)

Code doesn't run after flashing

Fix: Check for MicroPython errors, reset micro:bit (button on back)

Buttons don't work

Fix: Use button_a.was_pressed() not is_pressed()


General Tips

  1. Read error messages carefully - they tell you what's wrong!
  2. Check line numbers in errors
  3. Use print() to debug ("DEBUG: x =", x)
  4. Save often (Ctrl+S / Cmd+S)
  5. Ask for help - show the error message!