Report Bug
Qus :

What will be the output of the following Python code?

x = 'abcd'
for i in x:
    print(i)
    x.upper()

Qus

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

x = 'abcd'
for i in x:
    print(i)
    x.upper()


A. a B C D
B. a b c d
C. A B C D
D. error


Solution
B. a b c d



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



Report Bug