Python

Python: Replacing/Updating Elements in a List (with Examples)

Updated: June 6, 2023 By: Goodman

This concise, example-based article gives you some solutions to replace or update elements in a list in Python. Using indexing or slicing If you want to update or…

Python: How to Check If a List Is Empty (3 Approaches)

Updated: June 6, 2023 By: Khue

In Python, a list is a data structure that can store multiple values of different types in a sequential order. An empty list is a list that contains…

Python: Counting the Number of Elements in a List (4 Examples)

Updated: June 6, 2023 By: Goodman

This quick article shows you how to count the number of elements in a list in Python. Using the len() function The built-in len() function takes a list…

Python: 6 Ways to Iterate Through a List (with Examples)

Updated: June 6, 2023 By: Khue

Using a for loop Using a for loop is the most common approach to iterating through a list in Python. You can access each element individually and perform…

Python: How to Access Elements in a List

Updated: June 5, 2023 By: Khue

In Python, there are two main ways to access elements in a list. The first approach is to use indices, and the second one is to use list…

How to Create a List in Python (4 Approaches)

Updated: June 13, 2023 By: Khue

This concise, practical article walks you through a couple of different ways to create a list in Python 3. Using square brackets This approach is often used to…

Python: How to Convert a Number to a Byte Array

Updated: June 4, 2023 By: Khue

This step-by-step article will show you how to convert numbers (both integers and floats) to byte arrays in Python. We will make use of the struct module to…

Python: How to format large numbers with comma separators

Updated: June 4, 2023 By: Goodman

In Python, there are two easy ways to format large numbers with commas as separators to improve the readability of information (when printing to the console or displaying…

Python: Reverse the Order of Digits in a Number (2 Approaches)

Updated: June 4, 2023 By: Khue

This concise and straight-to-the-point article brings to the table two different ways to reverse the order of digits in a given number (integer or float) in Python. Using…

Python: Get Numeric Value from User Input

Updated: June 4, 2023 By: Khue

In Python, you can get numeric data from user input by using the input() function in combination with error handling. Below are the main steps: Code example: Run…

1 53 54 55 56 57 64