LearnFrenzy
Sign in Take a free test

Strings · Find the Error · Question 9

Error: append() on a string Answer, explanation & discussion

  • Find the error
  • Easy
  • 0 comments
  • Answer explained
  • Moderated community
Question 9 Back to Exercise

The program below stops with an error. Which statement correctly describes the problem?

main.py
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!

Post your comment

Comments appear after a quick review by our team.

Search LearnFrenzy

Esc

Quick links