🛠️ Scheduled Maintenance | We’ll be undergoing scheduled maintenance and upgrades between 00:00 PST Jan 26th until 00:00 PST Jan 28th. There may be brief interruption of services in that period. We apologize for the inconvenience.

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.
Anybody can ask a question
Anybody can answer
The best answers are voted up and moderated by our team

Syntax warning

Syntax warning

Super Learner

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

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.