Register to get access to free programming courses with interactive exercises

Lists Python: Lists

A list is a data structure designed to store ordered sets of elements.

In this case, the word "ordered" means we store the structural elements in the order in which we added them.

Items in the list are indexed, meaning they have a number that tells you their position. The numbering always starts from zero and is always monotonous. It means that each subsequent item index increases by one — this numbering is also called continuous numbering. If you delete items at the beginning or middle of the list or insert items in the middle, Python recalculates the indexes and preserves the above numbering properties.

Immutability and modifiability

We already know that concatenating two lines results in a new line, and adding two numbers results in a number.

Tuples, which we looked at earlier:

  • Allow you to group the elements and then break the group into components
  • Can be combined into a larger tuple
  • Don't allow you to change the composition of the elements — instead, create new tuples from the elements of the old ones

Earlier, we discussed many data types and structures, such as strings, numbers, Boolean values, and tuples. They are immutable, meaning that once we create them, they don't change.

Lists are the first data structure that can change its contents on the fly. These objects are called changeable objects. However, some list operations still create new lists based on old lists.


Are there any more questions? Ask them in the Discussion section.

The Hexlet support team or other students will answer you.

For full access to the course you need a professional subscription.

A professional subscription will give you full access to all Hexlet courses, projects and lifetime access to the theory of lessons learned. You can cancel your subscription at any time.

Get access
130
courses
1000
exercises
2000+
hours of theory
3200
tests

Sign up

Programming courses for beginners and experienced developers. Start training for free

  • 130 courses, 2000+ hours of theory
  • 1000 practical tasks in a browser
  • 360 000 students
By sending this form, you agree to our Personal Policy and Service Conditions

Our graduates work in companies:

Bookmate
Health Samurai
Dualboot
ABBYY
Suggested learning programs
profession
new
Developing web applications with Django
10 months
from scratch
under development
Start at any time

Use Hexlet to the fullest extent!

  • Ask questions about the lesson
  • Test your knowledge in quizzes
  • Practice in your browser
  • Track your progress

Sign up or sign in

By sending this form, you agree to our Personal Policy and Service Conditions
Toto Image

Ask questions if you want to discuss a theory or an exercise. Hexlet Support Team and experienced community members can help find answers and solve a problem.