Q. What will the following code print?

Code:
x = [1, 2, 3]
x.append([4, 5])
print(len(x))
  • (A) 3
  • (B) 4
  • (C) 5
  • (D) Error
πŸ’¬ Discuss
βœ… Correct Answer: (B) 4
Explanation: `append()` adds the whole list as a single element, so length becomes 4.
Explanation by: Mr. Dubey
`append()` adds the whole list as a single element, so length becomes 4.

πŸ’¬ Discussion


πŸ“Š Question Analytics

πŸ‘οΈ
71
Total Visits
πŸ“½οΈ
1 y ago
Published
πŸŽ–οΈ
Mr. Dubey
Publisher
πŸ“ˆ
97%
Success Rate