Question 8
Back to Exercise
The program below stops with an error. Which statement correctly describes the problem?
age = 21
print("Age: " + age)
- A NameError: age is not defined
- B SyntaxError: missing comma
- C It prints Age: 21
- D TypeError: + cannot join a str and an int; use str(age), a comma or an f-string Correct
Correct Answer: Option D
Python never converts types silently here. Fixes: "Age: " + str(age), print("Age:", age) or f"Age: {age}".
Discussion & Comments 0
Share your method, a shortcut, or ask about a step you didn't follow.
No comments yet. Be the first to share your solution!