table string methods # syntax description strip(charsreturns copy of with leading and trailing whitespace (or the characters in str charsremovedstr lstrip(strips only at the startand str rstrip(strips only at the end swapcase(returns copy of with uppercase characters lowercased and lowercase characters uppercasedsee also str lower(and str upper( title(returns copy of where the first letter of each word is uppercased and all other letters are lowercasedsee str istitle( translate(companion of str maketrans()see text for details upper(returns an uppercased copy of ssee also str lower( zfill(wreturns copy of swhich if shorter than is padded with leading zeros to make it characters long which search method we use is purely matter of taste and circumstancealthough if we are looking for multiple index positionsusing the str index(method often produces cleaner codeas the following two equivalent functions illustratedef extract_from_tag(tagline)def extract_from_tag(tagline)opener "opener "closer "closer "tryi line find(openeri line index(openerif !- start len(openerstart len(openerj line index(closerstartj line find(closerstartreturn line[start:jif !- except valueerrorreturn line[start:jreturn none return none both versions of the extract_from_tag(function have exactly the same behavior for exampleextract_from_tag("red""what rose this is"returns the string "rosethe exception-handling version on the left separates out the code that does what we want from the code that handles errorsand the error return value version on the right intersperses what we want with error handling the methods str count()str endswith()str find()str rfind()str index()str rindex()and str startswith(all accept up to two optional argumentsa start position and an end position here are couple of equivalences to put this in contextassuming that is string