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


PYTHON TUTORIALS » String » Strip »

 

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



Leave a Comment / Note


 
Verification is used to prevent unwanted posts (spam). .


PYTHON TUTORIALS

 Navioo String
» Strip