Hi team, I'm just wondering why it prompted out the syntax warning where I inputted the syntax as per taught?
1 answers ( 0 marked as helpful)
Hi Ethan! Thanks for reaching out. The reason for this error touches upon the difference between object equality and identity in Python. This is a large and separate topic but basically, literals in Python include strings, integers, gloats, lists, tuples etc. is and is not are not supposed to be used with literals - they are to compare whether different objects contain the same values. That's why, you can execute the following result to obtain True.
a = 50Or this one to obtain True again.
b = 50
a is b
c = 10Should you compare literals directly, you can use arithmetic operators (such as == for equality and != for inequality). Hope this helps.
d = 12
c is not d