Without strip (), bananas is present in the dictionary but with an empty string as value. With strip (), this code will throw an exception because it strips the tab of the banana line. I know. strip() returns a copy of the string in which all chars have been stripped from the beginning and the end of the string.

The string. strip (), string. stripleading (), and string. striptrailing () methods trim white space [as determined by character. iswhitespace ()] off either the front, back, or both front and back of the Ò€¦ How do i strip leading and trailing spaces from a string? For example, dog should become dog.