0

I was trying to execute some statements in the console in Pycharm using the 'is' operator to get to know its functions better, however I ran across something I couldn't find an explanation for. I didn't know why I was getting all these warnings but then the answer is displayed. Because I still can't post an image, here is what I wrote:

x ='abc'
y = 'abc'
print(x is y)
print(x is 'abc')

It displayed the following for the second print statement:(:1: SyntaxWarning: "is" with a literal. Did you mean "=="?) for five times before displaying (True)

Any help is appreciated. Thank you!

  • 1
    Check this https://stackoverflow.com/questions/13650293/understanding-pythons-is-operator – rozumir Feb 19 '21 at 14:10
  • In regards to "*Because I still can't post an image, here is what I wrote*" => there's a good reason we don't allow new contributors to post images. It is because [**we don't allow images of text (code/input/output/errors, or otherwise) on Stack Overflow**](https://meta.stackoverflow.com/questions/285551/why-not-upload-images-of-code-errors-when-asking-a-question). Luckily you decided to post it as text rather than as a link to an image, as many others incorrectly do. Questions with images of text/code/errors are not highly regarded and are routinely closed. – costaparas Feb 19 '21 at 14:15
  • Thank you so much! It really helped me. I am new to stackoverflow and still learning about this amazing platform. – Bashar Ghanem Feb 19 '21 at 18:15

0 Answers0