Python List insert() Method

How can you insert an element at a given index in a given list? Python’s insert() method is your friend. This tutorial shows you everything you need to know to help you master an essential method of the most fundamental container data type in the Python programming language. Definition and Usage: The list.insert(i, element) method … Read more

Python List extend() Method

How can you not one but multiple elements to a given list? Use the extend() method in Python. This tutorial shows you everything you need to know to help you master an essential method of the most fundamental container data type in the Python programming language. Definition and Usage The list.extend(iter) method adds all elements … Read more

How to Concatenate Lists in Python? [Interactive Guide]

So you have two or more lists and you want to glue them together. This is called list concatenation. How can you do that? These are six ways of concatenating lists: List concatenation operator + List append() method List extend() method Asterisk operator * Itertools.chain() List comprehension Output: What’s the best way to concatenate two … Read more

Python List append() Method

How can you add more elements to a given list? Use the append() method in Python. This tutorial shows you everything you need to know to help you master an essential method of the most fundamental container data type in the Python programming language. Definition and Usage The list.append(x) method—as the name suggests—appends element x … Read more

Python List append() vs extend()

A profound understanding of Python lists is fundamental to your Python education. Today, I wondered: what’s the difference between two of the most-frequently used list methods: append() vs. extend()? I shot a small video explaining the difference and which method is faster—you can play it as you read over this tutorial: Here’s the short answer … Read more

Python List Methods

The most important collection data type in Python is the list data type. You’ll use lists basically in all your future projects so take 3-5 minutes and study this short guide carefully. You can also play my short video tutorial as you read over the methods: Method Description lst.append(x) Appends element x to the list … Read more

What are Regular Expressions Used For? 10 Applications

The web is full of tutorials about regular expressions. But I realized that most of those tutorials lack a thorough motivation. Why do regular expressions exist? What are they used for? What are some practical applications? Somehow, the writers of those tutorials believe that readers are motivated by default to learn a technology that’s complicated … Read more

Python Re Groups

This tutorial explains everything you need to know about matching groups in Python’s re package for regular expressions. You may have also read the term “capture groups” which points to the same concept. As you read through the tutorial, you can also watch the tutorial video where I explain everything in a simple way: Related … Read more

A Simple Python Morse Code Translator

Morse code was developed in telecommunications to encode the alphabetic characters in binary signals (“long” and “short”, or “1” and “0”). Here’s the Morse code table: This tutorial shows you how to implement a simple Morse code translator in Python. You can also play the explainer video as you read through the article: The code … Read more