+ 4

Why output 3 but no 2?

a = [1,2] b=a a.append(1) print(len(b))

15th May 2020, 8:11 PM
💡Arno Gevorgyan 🐍
💡Arno Gevorgyan 🐍 - avatar
4 ответов
+ 6
so b is a = True
15th May 2020, 8:18 PM
💡Arno Gevorgyan 🐍
💡Arno Gevorgyan 🐍 - avatar
+ 6
Lol thanks bro
15th May 2020, 8:27 PM
💡Arno Gevorgyan 🐍
💡Arno Gevorgyan 🐍 - avatar
+ 5
Because of "b=a"...... "b" and "a" refer to the same list...print their id's to check.
15th May 2020, 8:14 PM
rodwynnejones
rodwynnejones - avatar
+ 2
lol...didn't think to suggest using "is"....but yes...that correct.
15th May 2020, 8:25 PM
rodwynnejones
rodwynnejones - avatar