0
if text1 = text2 is True then why textlist1 != textlist 2 ?
text1 = "korea" text2 = "korea" textlist1 =[1, 2, 3] textlist2 =[1, 2, 3] print(text1 is text2) print(textlist1 is textlist2)
4 ответов
+ 5
Go through this:
https://code.sololearn.com/c89ejW97QsTN/?ref=app
+ 3
An array is an object, and when comparing two objects it checks if they are the same object, it doesn't check the values inside the array.
Try running this code:
arr1 = [1, 2, 5]
arr2 = arr1
arr2[0] = 7
print(arr1)
You should see that when you assigned arr1 to arr2 and changed arr2, the values also changed in arr1, because they refer to the same object.
+ 3