🚀 Hurry! Offer Ends In
00 Days
00 Hours
00 Mins
00 Secs
Enroll Now
X

निम्नलिखित कोड का आउटपुट क्या होगा?

What will be the output of following code ?

x = ['XX', 'YY']
     for i in x
     i.lower()
print(x)
A)
B)
C)
D)

Explanation:

Let's break down the code step by step:

x = ['XX', 'YY']
for i in x:
    i.lower()
print(x)

Explanation:

  1. List x: The list x = ['XX', 'YY'] contains two strings: 'XX' and 'YY'.

  2. The for loop:

    • The loop goes through each element in x, and for each string i, it calls the lower() method. However, lower() does not modify the string in place. Strings are immutable in Python, meaning the lower() method returns a new string but does not change the original one.
  3. The print(x):

    • After the loop completes, the list x is still unchanged because lower() was applied to each string but its result was not stored back in x.

Thus, the list x remains as ['XX', 'YY'].

Answer:

(A) ['XX', 'YY']

Latest Updates