Every Python developer encounters errors, especially when starting out. Instead of being frustrated by them, treat errors as clues that help you understand how Python works.
1. SyntaxError: EOL while scanning string literal
EOL stands for End Of Line. Python reads your string from the opening quote and expects a matching closing quote on the same line. If it reaches the end of the line without finding one, it throws this error.
# ❌ Broken — closing quote missing
print("Hello, Parthi)
# ✅ Fixed
print("Hello, Parthi")
2. IndentationError: unexpected indent
Python uses whitespace to define structure, no curly braces. Every block (inside an if, a for, a function) must be indented consistently. An unexpected indent means a line has leading spaces where Python expected none.
# ❌ Broken — indented for no reason
name = "Parthi"
print(name)
# ✅ Fixed — back at the base level
name = "Parthi"
print(name)
# ✅ Also valid — indented correctly inside a block
if name == "Parthi":
print("Welcome!")
3. NameError: name '…' is not defined
Python evaluates names at runtime. If you reference a variable that hasn't been assigned yet or you've misspelled it, NameError occurs.
# ❌ Broken — used before assignment
print(total)
total = 100
# ❌ Broken — typo (underscore vs no underscore)
username = "parthi"
print(user_name)
# ✅ Fixed
total = 100
print(total)
username = "parthi"
print(username)
Errors happen to everyone; Keep going.