123var = "hello"
What is starting a variable name with a number? (Variable names cannot begin with digits)
x = 2 ^ 3
What is using ^ for exponentiation? (In Python, ^ is the bitwise XOR operator. Exponentiation uses a double asterisk **).
print("Hello)
What is a missing closing quotation mark? (The string opens with a double quote ", but never closes).
is_active = true
What is using a lowercase true instead of capital True? (Python booleans are case-sensitive and must start with a capital letter: True or False).
print("Hello World"
What is a missing closing parenthesis )? (Every open parenthesis must have a matching closing one).
my age = 20
What is a space in the variable name (my age)? (Variable names cannot contain spaces; use underscores like my_age).
x++
What is trying to use a non-existent increment operator (++)?
need to use x += 1 or x = x + 1 instead.
print('It's sunny')
What is an unclosed string due to conflicting single quotes? ('It's' breaks because the single quote inside 'It's' prematurely closes the string).
x = "10" + 5
What is a TypeError trying to add a string and an integer ("10" + 5)? (Python won't implicitly add strings and numbers together).
if x == 5:
print(x)
What is a missing indentation (IndentationError)? (Python requires blocks after colons like if statements to be indented).
age = 15
print(Age)
What is a NameError due to case sensitivity? (Age has a capital 'A', but the variable was defined as lowercase age)
if x = 5:
What is using the assignment operator = instead of the comparison operator == in an if statement? (= assigns values, == compares them).
message = "Score: " + 100
What is a TypeError (concatenating a string and an integer)? (You cannot use + to join a string and an integer directly; you must wrap the number in str(100)).
my_list = [1, 2]<br>print(my_list.length)
What is using .length instead of the len() function? (Python lists don't have a .length property; you use len(my_list)).
print("A" + print("B"))
What is trying to concatenate with print() which returns None? (print("B") prints to the console and returns None, which cannot be added to string "A").
5 = x
What is assigning to a literal value (5 = x)? (You can't assign a variable to a number; the variable name must always be on the left side: x = 5).
x = 10 % 0
What is a ZeroDivisionError with the modulus operator (10 % 0)? (Just like division, dividing or finding the remainder with zero is illegal).
print("C:\newfolder")
What is an accidental escape character (\n)? (\n inside "C:\newfolder" is interpreted as a newline. Solution: use a raw string r"C:\newfolder")
x = int("hello")
What is a ValueError during type casting? (int("hello") fails because "hello" cannot be converted into a valid integer number).
for i in range(5)
print(i)
What is a missing colon : at the end of the for statement? (Control flow statements like for, if, and while must end with a colon).
global = "test"
What is using a reserved keyword (global) as a variable name? (Keywords built into Python like global, for, if, class cannot be used as variable names).
result = (5 + 3
What is an unmatched parenthesis (5 + 3? (Missing a closing parenthesis ) to finish the math expression).
text = "Hello
world"
What is an unterminated multi-line string? (A string spanning multiple lines needs triple quotes """ or ''', or line-continuation backslashes.)
if 5 > 3 and:
What is an incomplete logical expression after and? (Logical operators like and or or must have a condition on both sides).
x = 10
y = 0
print(x / y)
What is a ZeroDivisionError? (Dividing any number by 0 crashes the program).