Why does comparing strings in Python using either \'==\' or \'is\' sometimes produce a different result?

Answer

is is identity testing, == is equality testing. what happens in your code would be emulated in the interpreter like this:

>>> a ='pub'>>> b =''.join(['p','u','b'])>>> a == b
True>>> a is b
False

All windows Questions

Ask your interview questions on windows

Write Your comment or Questions if you want the answers on windows from windows Experts
Name* :
Email Id* :
Mob no* :
Question
Or
Comment* :
 





Disclimer: PCDS.CO.IN not responsible for any content, information, data or any feature of website. If you are using this website then its your own responsibility to understand the content of the website

--------- Tutorials ---