Skip to content

Python Lists

Python List Index Find First, Last or All Occurrences Cover Image

Python List Index: Find First, Last or All Occurrences

In 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

Python List Prepend Cover Image

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

Find Duplicates in a Python List Cover Image

Find Duplicates in a Python List

In 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

Python Multiply Lists Cover Image

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 Overview Cover Image

Python Lists: A Complete Overview

In 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

How to Select Random Items from a List in Python Cover Image

Python: Select Random Element from a List

Learn how to use Python to choose a random list element, with and without replacement and how to replicate results with a random seed.

Python Clear List Cover Image

4 Ways to Clear a Python List

Learn how to use Python to clear a list, using clear, del, and indexing methods, as well as some general attributes about Python lists.

Python Get Index of Max Item in List Cover Image

Python: Get Index of Max Item in List

Learn 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 Check if List Contains an Item Cover Image

Python: Check if List Contains an Item

Learn how to check if a Python list contains an element using different methods, including the in keyword, the count method, and more!