Close
Close

please explain the working of the following code

   Ultra_Zinka_Jarvis

a = "Config1"

print(a)

b = a

a += "config2"

print(a)

print(b)


Answers

  •    nishank

    Here, first we are assigning "Config1" to a, then printing it.

    Output of print(a) would be "Config1".

    Then we are initializing the value of b equal to a, i.e "Config1", thus b will be having value "Config1". Now, a += "config2" appends "config2" to the value of a i.e "Config1", therefore the value of a becomes "Config1config2", b is still having the value "Config1".

    On printing, the value of a would be "Config1config2" and value of b would be "Config1".



Ask Yours
Post Yours
Write your answer