T

Tanmay • 2.43K Points
Master

Q. What is the output of the following code?

Code:
l = ['ab', 'cd']
for i in l:
    i.upper()
print(l)
  • (A) [‘AB’, ‘CD’]
  • (B) [‘ab’, ‘cd’]
  • (C) [None, None]
  • (D) None of the above
  • Correct Answer - Option(B)
  • Views: 126
  • Filed under category Python

Explanation by: Tanmay
The upper() function does not modify the string. In this case, it returns a new string but we haven’t stored any.

You must be Logged in to update hint/solution

Discusssion

Login to discuss.

Be the first to start discuss.


Question analytics