Print Statements
print("Hello World!)
Missing close-quote
x = 5
if x = 5:
print(x)
Comparison operator is ==, not =
for i in range[5]:
print(i)
Must use (), not [], for the range function
my_tuple = (1, 2, 3)
my_tuple[1] = 5
Tuples are immutable, cannot reassign value
def greet (name:
print("Hello", name)
Missing closing parentheses ")" in definition
1st_number = 5
2nd_number = 6
total = 1st_number + 2nd_number
Improper variable names (cannot start with a number)
x = 15
if x > 10:
print("Large")
if x < 5:
print("Small")
else:
print("Medium")
Should use elif instead of if for second statement, will print:
"Large"
"Medium"
x = 5
while x < 10:
print(x)
Infinite loop, never increase x or have a break statement
my_list = [1, 2, 3]
print(my_list[3])
Index error, max index of my_list is 2
def add(a, b):
return a+b
print(add(2))
Missing argument/wrong number of arguments
r = float(input("Enter the radius of the circle:"))
pi = 3.14159265
circle_area = PI * r**2
PI not declared, pi is (case sensitive)
grade = 98
if grade >= 90:
"A"
Missing print statement or variable declaration for "A"
for i in 5:
print(i)
5 is not an iterable
my_list = [1, 2, 3, 4]
for i in range(len(my_list)):
print(my_list[i+1])
Final iteration of the loop will have the index out of bounds
def double(x):
x = x * 2
print(double(4))
Missing return statement
value = input("Enter a number:")
new_value = value + 5
Type error, must convert value to float/int first
age = 25
if age > 18 and < 30:
print("Young adult")
missing left comparison value in second comparison statement
for char in "Python"
print(char)
Missing colon at end of for loop statement
person = {"name": "Alice", "age": 21}
print(person["height"])
Key value "height" is not in the dictionary
def show():
print(msg)
msg = "Hello World!"
show()
msg is not defined within nor passed to the function, variable scope issue
name = "Emily"
print("Hello {name}!")
Must use an f-string to format the name variable this way
score = 10
if score != 0:
if score % 2 == 0:
print("Even")
else:
print("Odd")
else:
print("Zero")
Indentation error, nested if and else statement blocks must be indented again
for i in range(10):
if i % 2 == 0:
continue
else:
print(i, "is Even")
== should be !=, currently prints the odd numbers are even
my_list = [1, 2, 3]
my_list.append[4]
print(my_list)
def factorial(n):
return n * factorial(n-1)
print(factorial(5))
Missing base case, function runs infinitely