On this page, you’ll find a list of Python tutorials, broken down by their topics.
Table of Contents
Python Lists
Python lists
are mutable, heterogenous, and ordered data structures that are frequently used to store different types of data. In the tutorials below, you’ll learn a number of different helpful skills to be able to better understand, use, and manipulate Python lists. Lists are intuitive and approachable, making them an important skill to master.
Featured Python List Articles
The articles listed below are represent comprehensive guides to be able to better work with key features of Python lists.
List Comprehensions in Python (Complete Guide with Examples) allows you to understand a key feature of Python. Comprehensions represent a key way to loop over and manipulate lists, or to generate new lists in a readable and intuitive way.
Python List Tutorials
- Fix ValueError: Too Many Values to Unpack in PythonIn this post, you’ll learn how to fix one of the most common Python errors: ValueError Too Many Values to Unpack. The error occurs when the number of variables being assigned is different from the number of values in the iterable. By the end of this tutorial, you’ll have learned how: The Quick Answer: Match Assignment Variables to the Number of Values In order to resolve the error, you simply need to match the number of assignment variables to the number of values in an iterable. Let’s take a look at an example that throws the error: In order to… Read More »Fix ValueError: Too Many Values to Unpack in Python
- How to Append a Dictionary to a List in PythonPython lists are mutable objects that can contain different data types. Because of this, you’ll often find yourself appending items to lists. In this tutorial, you’ll learn how to append a dictionary to a list in Python. While this may seem like a trivial task, there is a little complexity to it. Don’t worry, though! By the end of this tutorial, you’ll understand why some unexpected behavior happens and how to resolve it. By the end of reading this tutorial, you’ll have learned the following: How to append a dictionary to a list in Python Why you need to append… Read More »How to Append a Dictionary to a List in Python
- How to Append a String to a List in PythonPython 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 to a list is a common operation. In this tutorial, you’ll learn how to append a string to a list in Python. You may have tried to add a string to Python and saw some unexpected results. Perhaps, this is why you’re here! Well, look no further – you’ll learn all you need to know to be able to append… Read More »How to Append a String to a List in Python
- Difference Between Array and List in PythonIn this post, you’ll learn the difference between arrays and lists in Python. Both these data structures let you store data in Python and share many similar properties. However, they also let you do quite different things and knowing when to use which can make you a much stronger programmer! In particular, you’ll learn how the Python list is different from both the array and the NumPy array. You’ll get a strong understanding of when to use either of these data structures. By the end of this tutorial, you’ll have learned: How Python lists and arrays are similar and how… Read More »Difference Between Array and List in Python
- Python: Differences Between Lists and TuplesIn this tutorial, you’ll learn the differences between Python lists and tuples. Lists and tuples are fundamental Python container data structures. On the surface, they seem very similar. However, there are a number of unique differences between them that makes their use cases quite clear. By the end of this tutorial, you’ll have learned: What the key differences and similarities are between Python Lists and Python Tuples When using a list is more appropriate than using a tuple When using a tuple is more appropriate than using a list What methods are and aren’t available for the two data structures… Read More »Python: Differences Between Lists and Tuples
- How to Check if a Python List is EmptyIn this tutorial, you’ll learn how to use Python to check if a list empty. Python lists are one of the most versatile and widely-used container objects. Because Python lists are iterable, you may often want to first check if a list is empty, before attempting to iterate over a list. Without this, your program may run into issues and crash. By the end of this tutorial, you’ll have learned: How to use Python to check if a list is empty Why you would want to check if a Python list is empty How to check if a list of… Read More »How to Check if a Python List is Empty
- How to Iterate (Loop) Over a List in PythonIn this tutorial, you’ll learn how to iterate (or loop) over a list in Python. You’ll learn how to iterate with for loops, while loops, comprehensions, and more. What’s more, is that you’ll learn when each of these methods is the best method to use. Given that there are many different ways of accomplishing this, it can be helpful to understand which method to use. Python lists are one of the cornerstone data structures in the language. They are ordered and indexable, meaning that their order matters and that you can access items based on their order. They’re also heterogeneous,… Read More »How to Iterate (Loop) Over a List in Python
- Python List sort(): An In-Depth Guide to Sorting ListsIn this tutorial, you’ll learn how to use Python to sort a list using the sort() method. Being able to work with lists is an essential skill in Python, given their prevalence. Because lists are ordered and mutable data structures, we can modify their order. The list.sort() method allows you to do exactly this! The method is a valuable method that allows you to sort in many custom ways. By the end of this tutorial, you’ll have learned: How to use the Python sort method to sort a list How to sort in ascending, descending and custom orders How to sort lists of lists, lists… Read More »Python List sort(): An In-Depth Guide to Sorting Lists
- Python List Extend: Append Multiple Items to a ListIn this tutorial, you’ll learn how to use the Python list extend method, which lets you append multiple items to a list. The Python .extend() method is very similar to the Python .append() method, but lets you add multiple elements to a list at once. You’ll learn how to use the Python extend method to add a single item or multiple items to a list, including from other lists, tuples, and more. By the end of this tutorial, you’ll have learned: How the Python list extend method works How to add a single item or multiple items to a list… Read More »Python List Extend: Append Multiple Items to a List
- Python: Find List Index of All Occurrences of an ElementIn this tutorial, you’ll learn how to use Python to find the list index of all occurrences of an element. In many cases, Python makes it simple to find the first index of an element in a list. However, because Python lists can contain duplicate items, it can be helpful to find all of the indices of an element in a list. By the end of this tutorial, you’ll have learned: How to find the indices of all occurences of an element in a Python list using: For loops, List comprehensions, NumPy, and more_itertools Which method is fastest Let’s get… Read More »Python: Find List Index of All Occurrences of an Element
- Convert a List of Dictionaries to a Pandas DataFrameIn this tutorial, you’ll learn how to convert a list of Python dictionaries into a Pandas DataFrame. Pandas provides a number of different ways in which to convert dictionaries into a DataFrame. You’ll learn how to use the Pandas from_dict method, the DataFrame constructor, and the json_normalize function. By the end of this tutorial, you’ll have learned: How to convert a list of dictionaries to a Pandas DataFrame How to work with different sets of columns across dictionaries How to set an index when converting a list of dictionaries to a DataFrame How to convert nested dictionaries to a Pandas… Read More »Convert a List of Dictionaries to a Pandas DataFrame
- Generate Random Numbers in PythonIn this tutorial, you’ll learn how to generate random numbers in Python. Being able to generate random numbers in different ways can be an incredibly useful tool in many different domains. Python makes it very easy to generate random numbers in many different ways. In order to do this, you’ll learn about the random and numpy modules, including the randrange, randint, random, and seed functions. You’ll also learn about the uniform and normal functions in order to create more controlled random values. By the end of this tutorial, you’ll have learned: Generate Random Floating Point Value in Python Python comes… Read More »Generate Random Numbers in Python
- Python List Index: Find First, Last or All OccurrencesIn this tutorial, you’ll learn how to use the Python list index method to find the index (or indices) of an item in a list. The method replicates the behavior of the indexOf() method in many other languages, such as JavaScript. Being able to work with Python lists is an important skill for a Pythonista of any skill level. We’ll cover how to find a single item, multiple items, and items meetings a single condition. By the end of this tutorial, you’ll have learned: How the Python list.index() method works How to find a single item’s index in a list… Read More »Python List Index: Find First, Last or All Occurrences
- Prepend to a Python a List (Append at beginning)In this tutorial, you’ll learn how to use Python to prepend a list. While Python has a method to append values to the end of a list, there is no prepend method. By the end of this tutorial, you’ll have learned how to use the .insert() method and how to concatenate two lists to prepend. You’ll also learn how to use the deque object to insert values at the front of a list. In many cases, this is the preferred method, as it’s significantly more memory efficient than other methods. The Problem with Prepending a Python List Python lists are… Read More »Prepend to a Python a List (Append at beginning)
- Find Duplicates in a Python ListIn this tutorial, you’ll learn how to find and work with duplicates in a Python list. Being able to work efficiently with Python lists is an important skill, given how widely used lists are. Because Python lists allow us to store duplicate values, being able to identify, remove, and understand duplicate values is a useful skill to master. By the end of this tutorial, you’ll have learned how to: Find duplicates in a list, as well as how to count them Remove duplicates in Python lists Find duplicates in a list of dictionaries and lists Let’s get started! How to… Read More »Find Duplicates in a Python List
- Python: Multiply Lists (6 Different Ways)Learn how to use Python to multiply lists, including multiplying lists by a number and multiplying lists element-wise using numpy.
- Python Lists: A Complete OverviewIn this tutorial, you’ll learn all you need to know to get started with Python lists. You’ll learn what lists are and how they can be used to store data. You’ll also learn how to access data from within lists by slicing and indexing data. You’ll learn how to add data to lists and as well as how to delete items. You’ll also learn how to create lists of lists, which can often be used to represent matrices of data. What are Python Lists Python lists are a data collection type, meaning that we can use them as containers for… Read More »Python Lists: A Complete Overview
- Python: Select Random Element from a ListLearn how to use Python to choose a random list element, with and without replacement and how to replicate results with a random seed.
- 4 Ways to Clear a Python ListLearn how to use Python to clear a list, using clear, del, and indexing methods, as well as some general attributes about Python lists.
- Python IndexError: List Index Out of Range Error ExplainedLearn how to resolve the Python IndexError, list index out of range, why it occurs in for loops, while loops, and how to resolve it.
- Python: Get Index of Max Item in ListLearn how to use Python to get the index of the max item in a list, including when duplicates exist, using for loops, enumerate, and numpy.
- Python: Combine Lists – Merge Lists (8 Ways)Learn how to combine Python lists and how to merge lists, including in alternating sequence and with unique or common elements.
- Python: Check if List Contains an ItemLearn how to check if a Python list contains an element using different methods, including the in keyword, the count method, and more!
- Remove an Item from a Python List (pop, remove, del, clear)Learn how to remove an item from a Python list, using the pop, remove, and del methods. Also learn how to clear an entire list.
- How to Reverse a Python List (6 Ways)Learn how to use Python to reverse a list, including how to use the reversed function, list indexing, and a python list comprehension.
- Python: Replace Item in List (6 Different Ways)Learn how to replace an item or items in a Python list, including how to replace at an index, replacing values, replacing multiple values.
- Python: Remove Duplicates From a List (7 Ways)Learn how to use Python to remove duplicates from a list, including how to maintain order from the original list, using seven methods.
- Python: Convert a Dictionary to a List of Tuples (4 Easy Ways)Learn how to use Python to convert a dictionary into a list of tuples, using list comprehensions, the zip function, and collections.
- Python: Shuffle a List (Randomize Python List Elements)Learn how to use Python to shuffle a list, including being able to reproduce a given result and shuffling Python lists of lists.
- Python: Intersection Between Two ListsLearn how to find the intersection between two lists in Python, including using list comprehensions, set methods and the numpy library.
- Python: Subtract Two Lists (4 Easy Ways!)Learn how to use Python to subtract two lists, using the numpy library, the zip function, for-loops, as well as list comprehensions.
- Python List Length or Size: 5 Ways to Get Length of ListLearn how to use Python to find the length of a list, including using the built-in len() function, and findings lengths of lists of lists.
- Python: Transpose a List of Lists (5 Easy Ways!)Learn how to use Python to transpose a list of lists using numpy, itertools, for loops, and list comprehensions in this tutorial!
- Python: Split a List (In Half, in Chunks)Learn how to split a Python list into n chunks, including how to split a list into different sized sublists or a different number of sublists.
- Python: Combinations of a List (Get All Combinations of a List)Learn how to get all combinations of a Python list, including with substitution, using the helpful itertools library.
- Python: Flatten Lists of Lists (4 Ways)Learn how to use Python to flatten a list of lists, including using the itertools library, list comprehension, and multi-level lists of lists.
- Python List Difference: Find the Difference between 2 Python ListsLearn how to find the Python list difference to find the differences between two lists, including how to find the symmetric list difference.
- Python: Find Average of List or List of ListsIn this post, you’ll learn how to use Python to find the average of a list or a list of lists, using built-in tools and packages like numpy.
- How to Append to Lists in Python – 4 Easy Methods!Learn all the ways to append to lists in Python, including using the append, insert, and extend methods as well as how to concatenate lists!
- List Comprehensions in Python (Complete Guide with Examples)List Comprehensions provide easy and concise ways to generate lists in Python. Learn how to write list comprehensions in Python using this tutorial.
- 6 Ways to Convert a Python List to a StringIn this tutorial, you’ll learn how to use Python to convert (or join) a list to a string. Using Python to convert a list to a string is a very common task you’ll encounter. There are many different ways in which you can tackle this problem and you’ll learn the pros and cons of each of these approaches. By the end of this tutorial, you’ll have learned: How to use the .join() method to convert a Python list to a string How to use the map() function to convert a Python list to a string How to work with heterogenous… Read More »6 Ways to Convert a Python List to a String
Python Dictionaries
Python dictionaries are a built-in data type that uses a key:value
pair to store data. In other languages, similar data structures are known as associative arrays. They are ordered, changeable, and require keys to be unique.
Featured Python Dictionary Articles
Python Dictionary Comprehensions (With Examples) – learn all you need to know about how Python Dictionary Comprehensions work. Comprehensions represent a Pythonic way to generate new dictionaries, by iterating over different items and manipulating either (or both) the key or values of an array.
Python Dictionary Tutorials
- Fix ValueError: Too Many Values to Unpack in PythonIn this post, you’ll learn how to fix one of the most common Python errors: ValueError Too Many Values to Unpack. The error occurs when the number of variables being assigned is different from the number of values in the iterable. By the end of this tutorial, you’ll have learned how: The Quick Answer: Match… Read More »Fix ValueError: Too Many Values to Unpack in Python
- How to Append a Dictionary to a List in PythonPython lists are mutable objects that can contain different data types. Because of this, you’ll often find yourself appending items to lists. In this tutorial, you’ll learn how to append a dictionary to a list in Python. While this may seem like a trivial task, there is a little complexity to it. Don’t worry, though!… Read More »How to Append a Dictionary to a List in Python
- Convert JSON to a Python DictionaryIn this tutorial, you’re going to learn how to convert a JSON file or string into a Python dictionary. Being able to work with JSON data is an important skill for a Python developer of any skill level. In most cases, data you access through web APIs will come in the form JSON data. Being… Read More »Convert JSON to a Python Dictionary
- Python Nested Dictionary: Complete GuideIn this tutorial, you’ll learn about Python nested dictionaries – dictionaries that are the values of another dictionary. You’ll learn how to create nested dictionaries, access their elements, modify them and more. You’ll also learn how to work with nested dictionaries to convert them to a Pandas DataFrame. By the end of this tutorial, you’ll… Read More »Python Nested Dictionary: Complete Guide
- Copy a Python Dictionary: A Complete GuideIn this tutorial, you’ll learn all the different ways to copy a Python dictionary. While this may seem like a very rudimentary task, there are a number of complexities involved in this. In this tutorial, you’ll learn how to copy a dictionary reference-wise, create shallow copies, and create deep copies. By the end of this… Read More »Copy a Python Dictionary: A Complete Guide
- Convert a List of Dictionaries to a Pandas DataFrameIn this tutorial, you’ll learn how to convert a list of Python dictionaries into a Pandas DataFrame. Pandas provides a number of different ways in which to convert dictionaries into a DataFrame. You’ll learn how to use the Pandas from_dict method, the DataFrame constructor, and the json_normalize function. By the end of this tutorial, you’ll… Read More »Convert a List of Dictionaries to a Pandas DataFrame
- Find Duplicates in a Python ListIn this tutorial, you’ll learn how to find and work with duplicates in a Python list. Being able to work efficiently with Python lists is an important skill, given how widely used lists are. Because Python lists allow us to store duplicate values, being able to identify, remove, and understand duplicate values is a useful… Read More »Find Duplicates in a Python List
- Python Dictionaries: A Complete OverviewPython dictionaries are an incredibly useful data type, which allow you to store data in key:value pairs. In this tutorial, you’ll learn all you need to know to get up and running with Python dictionaries, including: Let’s get started! What are Python Dictionaries? Python dictionaries are container data types, like Python lists. Dictionaries use a… Read More »Python Dictionaries: A Complete Overview
- Python: Add Key:Value Pair to DictionaryIn this tutorial, you’ll learn how to add key:value pairs to Python dictionaries. You’ll learn how to do this by adding completely new items to a dictionary, adding values to existing keys, and dictionary items in a for loop, and using the zip() function to add items from multiple lists. What are Python dictionaries? Python… Read More »Python: Add Key:Value Pair to Dictionary
- Python: Sort a Dictionary by ValuesLearn to use Python to sort a dictionary by its values, ascending or descending, using sorted, for loops and dictionary comprehensions.
- Python Merge Dictionaries – Combine Dictionaries (7 Ways)Learn how to merge Python dictionaries, including how to deal with duplicate keys, and how to use the update method and merge operator.
- Python: Remove Duplicates From a List (7 Ways)Learn how to use Python to remove duplicates from a list, including how to maintain order from the original list, using seven methods.
- Python: Convert a Dictionary to a List of Tuples (4 Easy Ways)Learn how to use Python to convert a dictionary into a list of tuples, using list comprehensions, the zip function, and collections.
- Python: Pretty Print a Dict (Dictionary) – 4 WaysLearn how to use Python to pretty print a dictionary using the pprint and json libraries, including nested dictionaries and saving to a file.
- Python: Check if a Dictionary is Empty (5 Ways!)Learn how to check if a Python dictionary is empty, including five different ways to do this, including using simple booleans and its length.
- Python: Check if a Key (or Value) Exists in a Dictionary (5 Easy Ways)Learn how to use Python to check if a key (or a value) exists in a dictionary in a safe way, using the get method, in operator, and more!
- Python: Get Dictionary Key with the Max Value (4 Ways)Learn how to use Python to get the dictionary key with the max value, including when the max value is in multiple keys.
- Python: Remove Key from Dictionary (4 Different Ways)Learn how to remove a Python dictionary key, using the pop method, the del keyword, and how to remove multiple Python dictionary keys.
- Pretty Print a JSON File in Python (6 Methods)Learn how to use Python to pretty print a JSON object, including from a file, from an API, and how to save the pretty output to a file.
Python Strings
Python strings are surrounded by single, double, or triple quotes and are immutable (meaning they need to be reassigned to be altered), are ordered (meaning they can be indexed) and are incredibly common ways to hold information. Because of this, knowing how to work with strings is an important skill for any Pythonista. The tutorials below will teach you common ways to work with strings, often describing many different ways to fit your own personal programming style!
- Python Capitalize Strings: A Guide to Capitalizing WordsBeing able to work with strings in Python is an essential skill for a Pythonista of any level. In this tutorial, you’ll learn how to use Python to capitalize strings, including single words, title casing, and capitalizing lists of strings. In many cases, working with text in Python requires extensive data cleaning – knowing the… Read More »Python Capitalize Strings: A Guide to Capitalizing Words
- Python strip: How to Trim a String in PythonIn this tutorial, we’ll dive into the world of Python string trimming! String trimming is an essential skill that helps you clean up and refine your text data, making it more accurate and easier to work with. For example, being able to remove certain characters from a string in Python is an important pre-processing step… Read More »Python strip: How to Trim a String in Python
- Python Reverse String: A Guide to Reversing StringsLearn how to use Python to reverse a string. Learn how to use 6 ways, including developing a custom function to make your code more readable.
- How to Remove a Prefix or Suffix from a String in PythonWhen 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. Similarly, you may want to remove salutations, such as ‘Mr.’ from a name. In this… Read More »How to Remove a Prefix or Suffix from a String in Python
- 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 a string to title case, meaning that the first letter of each word in a… Read More »Convert a String to Title Case in Python with str.title()
- How to Append a String to a List in PythonPython 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 to a list is a common operation. In this tutorial, you’ll learn how to append… Read More »How to Append a String to a List in Python
- Python String startswith: Check if String Starts With SubstringThe 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 able to check if a string starts with another string is a useful way to… Read More »Python String startswith: Check if String Starts With Substring
- Python String endswith: Check if String Ends With SubstringThe 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 able to check if a string ends with another string allows you to, for example,… Read More »Python String endswith: Check if String Ends With Substring
- How to Remove First or Last Character From a Python StringWorking 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 remove the first or last character from a Python string. Similarly, you’ll learn how to… Read More »How to Remove First or Last Character From a Python String
- How to Fix: Python SyntaxError – EOL while scanning string literalIn this tutorial, you’ll learn how to fix one of the most common Python errors: SyntaxError – EOL while scanning string literal. There are three main causes for this error and this tutorial will help you resolve each of these causes. SyntaxErrors are indicative of errors with your code’s syntax. Since your code’s syntax is… Read More »How to Fix: Python SyntaxError – EOL while scanning string literal
- Python String Contains: Check if a String Contains a SubstringIn 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 more. Being able to work with strings in Python is an important skill for a… Read More »Python String Contains: Check if a String Contains a Substring
- How to Check if a String is Empty in PythonIn 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 are immutable, meaning that they cannot be changed once they’re created. Because of this, it… Read More »How to Check if a String is Empty in Python
- Python New Line and How to Print Without NewlineIn this tutorial, you’ll learn how to use the Python new line character and how to print without newlines. Being able to control how your program prints strings is an important skill, especially when working with text files or command-line interfaces (CLIs). In this tutorial, you’ll learn different ways to include a newline character in… Read More »Python New Line and How to Print Without Newline
- How to Concatenate Strings in Python: A Complete GuideIn this tutorial, you’ll learn how to use Python to concatenate strings. Being able to work with strings in Python is an important skill in almost every program you’ll write. In some cases, you’ll want to display text in your program and need to ensure code readability. In other cases, you will want to aim… Read More »How to Concatenate Strings in Python: A Complete Guide
- Python: Count Words in a String or FileIn this tutorial, you’ll learn how to use Python to count the number of words and word frequencies in both a string and a text file. Being able to count words and word frequencies is a useful skill. For example, knowing how to do this can be important in text classification machine learning algorithms. By… Read More »Python: Count Words in a String or File
- How to Make a List of the Alphabet in PythonIn this tutorial, you’ll learn how to use Python to make a list of the entire alphabet. This can be quite useful when you’re working on interview assignments or in programming competitions. You’ll learn how to use the string module in order to generate a list of either and both the entire lower and upper… Read More »How to Make a List of the Alphabet in Python
- Python: Concatenate a String and Int (Integer)Learn how to use Python to concatenate a string and an int, including how to use the string function, f-strings, % and +, and format.
- Python: Sort a String (4 Different Ways)Learn how to use Python to sort a string including how to sort strings using the sorted function, with case sensitivity or insensitivity.
- Python zfill & rjust: Pad a String in PythonIn this tutorial, you’ll learn how to use Python’s zfill method to pad a string with leadering zeroes. You’ll learn how the method works and how to zero pad a string and a number. You’ll also learn how to use the method in Pandas as well as how to use sign prefixes, such as +… Read More »Python zfill & rjust: Pad a String in Python
- Python: Int to Binary (Convert Integer to Binary String)Learn how to use Python to convert int to binary (integer to binary strings) using the format and bin functions, and string formatting.
- Python rfind: Find Index of Last Substring in StringUse the Python rfind method to find the last, or right-most, index of a substring in a Python string, including the difference to rindex.
- Python SHA256 Hashing Algorithm: ExplainedLearn how to implement Python SHA256 using the hashlib module, including working with unicode strings, files, and Pandas Dataframes.
- Python: Truncate a Float (6 Different Ways)Learn how to use Python to truncate a float using the int function, math library, string functions, f-strings, and truncate lists of numbers.
- Choose Between Python isdigit(), isnumeric(), and isdecimal()Learn how to use the Python isdigit, isnumeric, and isdecimal methods to check whether or not a string is a number and their differences.
- Python: Remove Special Characters from a StringLearn how to use Python to remove special characters from a string, including how to do this using regular expressions and isalnum.
- Python Lowercase String with .lower(), .casefold(), and .islower()Learn to use Python to lowercase text, using the lower and caseload functions, checking if strings are lower and converting lists to lower.
- Python Program to Check If a String is a Palindrome (6 Methods)Learn how to use Python to check if a string is a palindrome, using string indexing, for loops, the reversed function in Python!
- Python: Find All Permutations of a String (3 Easy Ways!)Learn how to use Python to find all permutations of a string, including using itertools, recursion, and a Python for loop.
- Python: Remove Punctuation from a String (3 Different Ways!)Learn to use Python to remove punctuation from a string, including using translate, regular expressions, and more – and which way is fastest!
- Python: Find an Index (or all) of a Substring in a StringLearn how to find the index of the first or last substring of a string using Python. Also learn how to find all indices of a substring.
- Python: Remove Newline Character from StringIn this post, you’ll learn how to use Python to remove newline characters from strings, including how to replace all or trailing newlines.
- Python: Remove a Character from a String (4 Ways)Learn how to use Python to remove a character from a string, using replace and translate. Learn to limit removals and multiple characters.
- Python: Count Number of Occurrences in a String (4 Ways!)Learn how to count the number of occurrences in a string using Python, including the built-in count method and the counter module.