Report Bug
Qus :

What will be the output of the following Python code snippet?

x = 'abcd'
for i in range(len(x)):
    x[i].upper()
print (x)

Qus

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

x = 'abcd'
for i in range(len(x)):
    x[i].upper()
print (x)


A. abcd
B. ABCD
C. error
D. none of the mentioned


Solution
A. abcd



Explanation
Changes do not happen in-place, rather a new instance of the string is returned.



Report Bug