Skip to content

Python Strings

Python Ord and Chr Functions Working with Unicode Cover Image

Python Ord and Chr Functions: Working with Unicode

In this tutorial, you’ll learn how to use the Python ord and chr functions to allow you to work better with Unicode. The Unicode standard has replaced many confusing encodings and is used to represent each character (including emojis) with

How to Remove a Prefix or Suffix from a String in Python

How to Remove a Prefix or Suffix from a String in Python

When working with strings in Python, you will often find yourself needing to remove a prefix or a suffix. For example, file names may be prefixed with a certain string and you want to remove that prefix when renaming files.

str title() and str istitle Convert a String to Title Case in Python Cover Image

Convert a String to Title Case in Python with str.title()

Being able to work with strings is an essential skill for a Python developer of any skill level. One of the most common operations you’ll run into is needing to capitalize different characters. For example, you may want to convert

How to Append a String to a List in Python

How to Append a String to a List in Python

Python lists are a common data type you’ll use to store data. Because they’re mutable (meaning they can be changed) and heterogeneous (meaning they can store different types of data), Python lists are very popular. Being able to add items

Python String startswith Check if String Starts With Substring Cover Image

Python String startswith: Check if String Starts With Substring

The Python startswith method is used to check if a string starts with a specific substring. In this tutorial, you’ll learn how to use the Python startswith function to evaluate whether a string starts with one or more substrings. Being

Python String endswith Check if String Ends With Substring Cover Image

Python String endswith: Check if String Ends With Substring

The Python endswith method is used to check if a string ends with a specific substring. In this tutorial, you’ll learn how to use the Python endswith method to evaluate whether a string ends with one or more substrings. Being

How to Remove First or Last Character From a Python String Cover Image

How to Remove First or Last Character From a Python String

Working with strings is an essential skill for a Python developer of any skill level. In many cases, this means cleaning strings, such as trimming either the front or end of a string. In this tutorial, you’ll learn how to

How to Use Python to Write a Text File (txt) Cover Image

How to Use Python to Write a Text File (.txt)

In this tutorial, you’ll learn how to use Python to write (or save) to a text file. Python provides incredible opportunity to read and work with text files – being able to save the output to a text file is

Python String Contains Check if a String Contains a Substring Cover Image

Python String Contains: Check if a String Contains a Substring

In this tutorial, you’ll learn how to use Python to check if a string contains another substring. There are a number of ways to use Python to check a string for a substring, including case insensitivity, checking for patterns, and

How to Check if a String is Empty in Python Cover Image

How to Check if a String is Empty in Python

In this tutorial, you’ll learn how to use Python to check if a string is empty or not. Being able to work with strings and see whether or not they are empty is an important skill to learn. Python strings