I couldn’t understand why this is happening actually..
Take a look at this python code :
word = raw_input("Enter Word")
length = len(word)
if word[length-1:] is "e" :
print word + "d"
If I give input “love”, its output must be “loved”. So, when I wrote this in PyScripter IDE, its neither showing error nor the output. But I tried the same code in python shell, its working!
I’d like to know why this is happening.
The
iskeyword will only work if the strings have exactly the same identity, which is not guaranteed even if the strings have the same value. You should use==instead ofishere to compare the values of the strings.Or better still, use
endswith: