Question 9
Back to Exercise
The program below stops with an error. Which statement correctly describes the problem?
code = "LF"
code.append("2026")
print(code)
- A TypeError: cannot add numbers
- B It prints LF2026
- C NameError: code is not defined
- D AttributeError: str has no append() method; strings are immutable – use code = code + "2026" Correct
Correct Answer: Option D
append belongs to list. For strings, concatenate and rebind.
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!