This querry is not w.r.t exercise but on "is" oprator in python .
Per my knowledge the operators "is" and "is not" test for object identity.
I am using 3.x version of python and observing different behaviour when I execute from python prompt and executing thru program.
Please help me understanding why there is different behaviour.
Below is the o/p for your reference , captured from python prompt and thru program.
Below is the output of python prompt: >>> a = "hello world" >>> b = "hello world" >>> print id(a),id(b) 34168608 34168648 >>> print hash(a),hash(b) -1500746465 -1500746465 >>> a is b False Below is the program and o/p: a = "hello world" b = "hello world" print id(a),id(b) print hash(a),hash(b) if a is b:print "Both ids are same" else: print "Both ids are different" >>> ================================ RESTART ================================ >>> 34144848 34144848 -1500746465 -1500746465 Both ids are same >>>