Wednesday, October 7, 2020

Answer for Syntax warning

https://365datascience.com/dwqa-answer/answer-for-syntax-warning/ -

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




#365datascience #DataScience #data #science #365datascience #BigData #tutorial #infographic #career #salary #education #howto #scientist #engineer #course #engineer #MachineLearning #machine #learning #certificate #udemy

No comments:

Post a Comment