निम्नलिखित कोड क्या प्रिंट करता है?
What does the following code print?
x = 'mohan'
for i in range(len(x)):
x[i].upper()
print (x)
A)
B)
C)
D)
Explanation:
The code doesn't change the string x
because strings are immutable in Python. The .upper()
method creates a new string but doesn't modify the original string. Therefore, x
remains 'mohan'
.
So, the output is: (A) mohan.