The 365 Data Science team is proud to invite you to our own community forum. A very well built system to support your queries, questions and give the chance to show your knowledge and help others in their path of becoming Data Science specialists.
Ask
Anybody can ask a question
Answer
Anybody can answer
Vote
The best answers are voted up and moderated by our team

Syntax warning

Syntax warning

Super Learner
0
Votes
1
Answer

Hi team, I’m just wondering why it prompted out the syntax warning where I inputted the syntax as per taught?

1 Answer

365 Team
0
Votes

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 = 50
b = 50
a is b

Or this one to obtain True again.

c = 10
d = 12
c is not d

Should you compare literals directly, you can use arithmetic operators (such as == for equality and != for inequality).
Hope this helps.
Best,
Martin