hopefully somebody here can help me with this problem. I'm doing some revision for a 1st year programming exam on Friday and ran into something confusing me.
In my lecture slides discussing mutability, there is a particular part which doesn't work for me. The example is:
a = 'this is a string'
b = 'this is a string'
print(a is b)
False
But when I enter this in my program, it returns True instead. Also their ID's are identical. Now I would expect if I printed a == b
it would return True
, but surely a
shouldn't be b
as they are individual variables.
This was also a question from last years exam so would be helpful to understand this.
Any help on this matter much appreciated.