A

Admin • 832.27K Points
Coach

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
  • Correct Answer - Option(B)
  • Views: 24
  • Filed under category Python
  • Hashtags:

Explanation by: Admin

`append()` adds the whole list as a single element, so length becomes 4.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.