Strings Methods
Strings Methods
1. str.lower()
2. str.upper()
3. str.strip()
4. str.split()
5. str.join()
o Joins elements of an iterable (e.g., list) into a string, separated by the string calling
the method.
6. str.replace()
7. str.find()
o Example: "hello".find('e') → 1
8. str.startswith()
9. str.endswith()
10. str.format()
1. str.title()
2. str.capitalize()
3. str.count()
o Example: "banana".count('a') → 3
4. str.isdigit()
5. str.isalpha()
6. str.isalnum()
7. str.lstrip()
8. str.rstrip()
9. str.zfill()
o Pads the string with zeros on the left to fill a specified width.
10. str.partition()
1. str.swapcase()
2. str.casefold()
3. str.index()
o Returns the index of the first occurrence of a substring, raises ValueError if not
found.
o Example: "hello".index('e') → 1
4. str.rfind()
o Example: "banana".rfind('a') → 5
5. str.rsplit()
6. str.center()
7. str.ljust()
8. str.rjust()
9. str.splitlines()
10. str.expandtabs()
1. str.islower()
2. str.isupper()
3. str.isspace()
4. str.isprintable()
5. str.isidentifier()
6. str.maketrans()
7. str.translate()
10. str.encode()
o Example: "hello".encode('utf-8')