i have code:
first = ['a','b'] second = first second.append('c') print('test results: ',first == second, first second) which returns test results: true true. expected false false. thought because second.append('c') appending 'c', 2 variables stores different objects - meaning first = ['a','b'] , second = ['a','b','c']
why true true?
because second = first not make copy. makes second , first 2 references same object.
Comments
Post a Comment