R

Ram Sharma • 3.40K Points
Extraordinary

Q. What does this code print?

Code:
def f():
return [i for i in range(3)]

print(len(f()))
  • (A) 2
  • (B) 3
  • (C) 1
  • (D) 0
  • Correct Answer - Option(B)
  • Views: 10
  • Filed under category Python
  • Hashtags:

Explanation by: Ram Sharma
The function returns a list with 3 elements: [0, 1, 2]. Length is 3.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.