Damn! C&P-bug here to! Is this a virus? ;-) > print [w for w in j.split() if words[0] == '*' and words[-1] == '*'] Should be: print [w for w in j.split() if w[0] == '*' and w[-1] == '*']