Mastering Python String Methods and Syntax
Case Manipulation Methods
- title(): Displays each word in a string in Title Case, where every word begins with a capital letter.
- upper(): Converts every character in a string to all uppercase letters.
- lower(): Converts every character in a string to all lowercase letters. This is particularly useful for normalizing user input before storing it.
Whitespace Stripping Methods
Python considers whitespace (tabs, spaces, etc.) significant. Use these methods to clean up extra spacing:
- rstrip(): Removes whitespace from the right side (end) of a string.
- lstrip(): Removes whitespace from the left side (beginning) of a string.
- strip(): Removes whitespace from both the beginning and the end of a string simultaneously.
Related Data Type Conversion
- str(): While not
English with a size of 2.83 KB