0

What is different between these?

if 1 is 1: print("yes") >>>yes if [1] is [1] : print("yes") >>>No output

21st Apr 2019, 6:48 AM
starter : L.L
starter : L.L - avatar
4 Réponses
+ 4
"is" compares the addresses, so your two lists are actually not the same See this for clarification: https://code.sololearn.com/cr8Tya93btDT/?ref=app
21st Apr 2019, 8:25 AM
Matthias
Matthias - avatar
+ 1
First, the statment is True, so return ‘Yes’ Second, the statmen is False, but it don’t have ‘else’. Then, it return No output.
21st Apr 2019, 9:17 AM
Michita Sato
Michita Sato - avatar
+ 1
I fully understood. I was very impressed with your coding(Matthias ). Thank you for your explanation!! :)
21st Apr 2019, 9:24 AM
starter : L.L
starter : L.L - avatar
0
I didn't clearly inquire Q. Superficially we may not know what the Q is. 🙁 Im sorry TT But thanks you gave me your time! Michita Sato
21st Apr 2019, 9:30 AM
starter : L.L
starter : L.L - avatar