Q: python string (with space) matching while trying to eliminate few strings in the list of strings, I tried to use a simple code similar to:
>>> s = ['a b', 'c d', 'e f', 'g h']
>>> for i in s:
...     if i is not 'e f':
...         print(i)
...
a b
c d
e f    # this should not get printed, right?
g h

and i am unable to understand the underlying behavior?
can u explain? because the following seems logical and above should also work accordingly
>>> if 'a b' is not 'a b':
...     True
... else:
...     False
...
False
>>> s = ['a', 'c', 'e', 'g']
>>> for i in s:
...     if i is not 'e':
...         print(i)
...
a
c
g

are spaces to be treated specially? What am i missing?

A: is not is an identity based test; when it works on strings, it's due to interning of strings or the small string cache; it's an implementation detail that should never be relied on.
Don't use is/is not in general, except for comparisons to None, until you really understand what it's doing. You want != here, which tests value (do the two objects represent the same logical information?), not is not, which tests identity (are both things referring to the exact same object?).
If you wanted to force this to work, you could do something terrible, like explicitly interning all the strings involved, but that doesn't save any work (the work is spent interning them), and it's generally frowned upon.
