Learning Python: Part 2: Lists

Learning Python

Python is a general-purpose interpreted programming language. It emphasizes readability through the use of whitespace and supports multiple programming paradigms such as functional and object-oriented models.


Many programming languages have a concept called arrays. In Python, this same functionality and structure is known as lists.

A list is an ordered, sequential set of data. Different entries of the set can be accessed through their index, the position within the data.

Like other types of variables in Python, they are created and used through the name of a variable.

A list is created through opening and closing square brackets. Whatever is inside the brackets is “in” the set of data.

Accessing Entries

A list starts with the 0th position. This is the first entry in the list. Each new entry after that increases the total by one each time. A list with two entries, then, has the positions 0 and 1 for its data.

Assigning a value to a position in a list changes that value if that position already exists. If it does not, an error will happen.

Adding and Removing

New values can be added to a list through two functions: append() and remove().

By supplying a new item to the function append(), it will be added to the list. Similarly, giving a value to remove() will search for and remove the item from the list.

Play with the example on Repl.it!