Doubt in class variables

class person:
nationality = “indian”

p1 = person()
p2 = person()
p1.nationality = “american”

print(p1.nationality)
print(p2.nationality)

####for this output is different,but if it is a class variable it should be same

Hello @Shivambansal0804,

class person:
    nationality = "indian"

p1 = person()
p2 = person()

person.nationality = "american"

print(p1.nationality)
print(p2.nationality)

This code prints:

american
american

I hope this code is self explanatory, but if you still get any issue, let me know.

Happy Learning :slightly_smiling_face: