String manipulation is one of those activities in programming that we, as programmers, do all the time.
In many programming languages, you have to do a lot of the heavy lifting by yourself.
In Python, on the other hand, you have several built-in functions in the standard library to help you manipulate strings in the most different ways you can think of.
In the following articles, I showcase these many features of the language regarding strings specifically along with some nice tricks.
You can also download a PDF version with all of these tips and a few more tricks on Python String Manipulation Handbook.
- How to Split a String in Python
- How to remove all white spaces in a string in Python
- Multiline Strings in Python
- lstrip(): removing spaces and chars from the beginning of a string in Python
- rstrip(): removing spaces and chars from the end of a string in Python
- strip(): removing spaces and chars from the beginning and end of a string in Python
- String Lowercase in Python
- String Uppercase in Python
- String Title Case in Python
- String Swap Case in Python
- Checking if a string is empty in Python
- rjust(): right-justified string in Python
- ljust(): left-justified string in Python
- isalnum(): checking alphanumeric only in a string in Python
- isprintable(): checking printable characters in a string in Python
- isspace(): checking white space only in a string in Python
- startswith(): checking if a string begins with a certain value in Python
- capitalize(): first character only to upper case in a string in Python
- isupper(): checking upper case only in a string in Python
- endswith(): check if a string ends with a certain value in Python
- join(): join items of an iterable into one string in Python
- splitlines(): splitting a string at line breaks in Python
- islower(): checking lower case only in a string in Python
- isnumeric(): checking numerics only in a string in Python
- isdigit(): checking digits only in a string in Python
- isdecimal(): checking decimals only in a string in Python
- isalpha(): checking letters only in a string in Python
- istitle(): checking if every word begins with an upper case char in a string in Python
- expandtabs(): set the number of spaces for a tab in a string in Python
- center(): centered string in Python
- zfill(): add zeros to a string in Python
- find(): check if a string has a certain substring in Python
- Removing a Prefix or a Suffix in a String in Python
- Python: lstrip() vs removeprefix() and rstrip() vs removesuffix()
- How to reverse a string in Python
- Understanding Slicing in Python
- String Interpolation with f-strings in Python