The strip method returns a string where whitespace on the left and right (but not internally) has been stripped (removed)
print ' internal whitespace is kept '.strip() names = ['gumby', 'smith', 'jones'] name = 'gumby ' if name in names: print 'Found it!' if name.strip() in names: print 'Found it!'