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

निम्नलिखित पायथन प्रोग्राम का आउटपुट खोजें।

Find the output of the following Python programs.

x=['ab','cd']
for i in x:
     i.upper()
print(x)
A)
B)
C)
D)

Explanation:
  • The upper() method: The upper() method returns a new string with all characters in uppercase. However, strings in Python are immutable, meaning that calling upper() on a string does not modify the original string in place. Instead, it returns a new string. In the loop, the result of i.upper() is not assigned to any variable or used, so it has no effect on the original list x.

  • The loop: The loop iterates through each string in the list x. For each string, i.upper() is called, but since the result is not used, the strings in the list x remain unchanged.

  • Printing the list x: After the loop finishes, the list x remains as ['ab', 'cd'] because no modifications have been made to it.

Latest Updates