Question
The code below should count numbers greater than 5 in [2, 4, 5, 7, 8, 10, 13] but has two bugs:
numbers = [2, 4, 5, 7, 8, 10, 13]
count = 1
for num in numbers:
if num <= 5:
count += 1
print("Number of numbers greater than 5:", count)
(a) Add print statements to trace num, the condition result, and count at each step.
(b) Identify both bugs.
(c) Fix the code. The correct answer is 4.