Common Python String Methods

By Lenin Mishra

If you prefer to watch Youtube videos over reading blogs, check out our video on Python strings here.

Python has a number of built-in methods that you can use on strings. None of those methods change the original string. They return new strings.

Python String Methods

Here is a list of commonly used Python string methods.

  1. capitalize() - Converts the first character to uppercase
  2. casefold() - Converts string into lower case
  3. center() - Returns a centered string
  4. count() - Returns the number of times a specified value occurs in a string
  5. encode() - Returns an encoded version of the string
  6. endswith() - Returns true if the string ends with the specified value
  7. expandtabs() - Sets the tab size of the string
  8. find() - Searches the string for a specified value and returns the position of where it was found
  9. format() - Formats specified values in a string
  10. format_map() - Formats specified values in a string
  11. index() - Searches the string for a specified value and returns the position of where it was found
  12. isalnum() - Returns True if all characters in the string are alphanumeric
  13. isalpha() - Returns True if all characters in the string are in the alphabet
  14. isdecimal() - Returns True if all characters in the string are decimals
  15. isdigit() - Returns True if all characters in the string are digits
  16. isidentifier() - Returns True if the string is an identifier
  17. islower() - Returns True if all characters in the string are lower case
  18. isnumeric() - Returns True if all characters in the string are numeric
  19. isprintable() - Returns True if all characters in the string are printable
  20. isspace() - Returns True if all characters in the string are whitespaces
  21. istitle() - Returns True if the string follows the rules of a title
  22. isupper() - Returns True if all characters in the string are upper case
  23. join() - Joins the elements of an iterable to the end of the string
  24. ljust() - Returns a left justified version of the string
  25. lower() - Converts a string into lower case
  26. lstrip() - Returns a left trim version of the string
  27. maketrans() - Returns a translation table to be used in translations
  28. partition() - Returns a tuple where the string is parted into three parts
  29. replace() - Returns a string where a specified value is replaced with a specified value
  30. rfind() - Searches the string for a specified value and returns the last position of where it was found
  31. rindex() - Searches the string for a specified value and returns the last position of where it was found
  32. rjust() - Returns a right justified version of the string
  33. rpartition() - Returns a tuple where the string is parted into three parts
  34. rsplit() - Splits the string at the specified separator, and returns a list
  35. rstrip() - Returns a right trim version of the string
  36. split() - Splits the string at the specified separator, and returns a list
  37. splitlines() - Splits the string at line breaks and returns a list
  38. startswith() - Returns true if the string starts with the specified value
  39. strip() - Returns a trimmed version of the string
  40. swapcase() - Swaps cases, lower case becomes upper case and vice versa
  41. title() - Converts the first character of each word to upper case
  42. translate() - Returns a translated string
  43. upper() - Converts a string into upper case
  44. zfill() - Fills the string with a specified number of 0 values at the beginning
  1. How to create a string in Python?
  2. How to access characters in a Python string?
  3. How to replace characters in a string in Python?
  4. How to concatenate strings in Python?
  5. How to iterate through a string in Python?
  6. Check if a Substring is Present in a Given String in Python
  7. Escape sequences in Python String
  8. Python String Formatting - The Definitive Guide