Category string

How to Split String by Commas in Python

In this simple tutorial, we will see how to split a string into a list of strings using the most common delimiter: the comma. Use the split() method to split a string by commas Python comes with a built-in method…

Lowercase a String in Python

When you’re dealing with strings in Python, you may want to convert them to lowercase. This is a standard practice to ensure that your data is consistent and that you don’t hold, unwillingly, duplicate entries. In this tutorial, I’ll explain…

Escape Quotes from String in Python

As you must already know, quotes are used in Python to delimiter a string. In other words, quotes are interpreted by Python as the beginning or end of a string. Nevertheless, you can face a situation where your string actually…

Remove Newline from a String in Python

Like many programming languages, Python has a newline character, represented by \n, which indicates that the string should be displayed in more than one line. If you look at the documentation of the print buil-in function, you’ll see that Python…

Remove a Substring from a String in Python

In this tutorial, we’ll tackle the different options you can use to remove a substring from a string in Python. You actually have countless options, but we’ll limit ourselves to the most common and practical ones. Use str.replace() method to…