+ 1

Print ("p" is "p", [] is [])

what is the output and why?!

21st Dec 2017, 7:55 PM
Watch Me Fail
Watch Me Fail - avatar
4 Respuestas
+ 3
Well if you write p=[] and then s=[], it will be two different empty lists because they use different parts of RAM while executing code. That's why two empty lists in the left and right from 'is' are different empty lists.
21st Dec 2017, 8:24 PM
Petr Leliaev
Petr Leliaev - avatar
+ 6
Plus you have to define the 'p' variable, first :)
21st Dec 2017, 8:01 PM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 3
Both outputs are False. 'Is' returns True only if two expressions are the same objects, but it's not enough for them to have the same values.
21st Dec 2017, 8:00 PM
Petr Leliaev
Petr Leliaev - avatar
+ 1
i edit the question but when i try it [] is [] it gives a false while both are empty lista if I'm not wrong
21st Dec 2017, 8:13 PM
Watch Me Fail
Watch Me Fail - avatar