The strip method returns a string where whitespace on the left and right (but not internally) has been stripped (removed): : Strip « String « Python Tutorial






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!'








5.34.Strip
5.34.1.The strip method returns a string where whitespace on the left and right (but not internally) has been stripped (removed):
5.34.2.specify which characters are to be stripped, by listing them all in a string parameter
5.34.3.Strip leading and trailing characters