Python

The modern Python regular expressions cheat sheet

Updated: May 25, 2023 By: Goodman

This page provides a comprehensive, example-style cheat sheet about regular expressions in Python. I myself use it quite regularly in my work. You can bookmark it to quickly…

Python: Converting a string to lowercase/uppercase

Updated: May 25, 2023 By: Frienzied Flame

In Python, you can use the str.lower() and str.upper() methods to change the case of all characters in a string to lowercase or uppercase, respectively. These methods have…

Python: 5 ways to check if a string contains a substring

Updated: May 25, 2023 By: Khue

This succinct, practical article will walk you through several different ways to check whether a string contains a specific substring in Python. I assume you already have some…

Python: 4 Ways to Convert a String into a List

Updated: May 25, 2023 By: Frienzied Flame

This concise, example-based article walks you through four different ways to turn a given string into a list in Python. Life is short, and time is precious; let’s…

Python: 3 Ways to Hash a Password

Updated: May 25, 2023 By: Khue

Overview This concise article shows you three different ways to hash a password in Python. Before seeing the code, let’s clarify some concepts and jargon. This part is…

Python String Slicing: Tutorial & Examples

Updated: May 24, 2023 By: Wolf

Overview In Python, string slicing allows you to extract specific portions, or substrings, from a string by specifying the start and end indices. Syntax: Where: Some main points…

Python: 5 Ways to Reverse a String

Updated: May 24, 2023 By: Wolf

When writing code with Python, there might be cases where you need to reverse a string, such as when you want to check if a string is a…

Python: Remove leading/trailing whitespace from a string

Updated: May 24, 2023 By: Goodman

This concise, straightforward article will show you a couple of different ways to trim leading and trailing whitespace from a given string in Python. Overview You can skip…

4 Ways to Format a String in Modern Python

Updated: May 24, 2023 By: Wolf

Using f-strings or formatted string literals (Python 3.6+) This method allows you to embed variables and expressions directly into string literals by prefixing the string with f (that’s…

The modern Python strings cheat sheet

Updated: May 24, 2023 By: Wolf

This page provides a comprehensive, example-style cheat sheet about strings in modern Python (Python 3.10 and newer versions). I also use it quite often for quick lookups when…

1 58 59 60 61 62 64