Lists in Python
Python courses for children teach the basic principles of writing code.
Students create a variety of programs. At each lesson, there is a task on the subject of the lesson. The basis of our course is understanding the theory and fixing it in practice, we devote more time to practice.
List Functions and Methods
Lists in Python are ordered, replaceable collections of objects of larger types. They differ from body weight, which types can vary – from numbers to whole series. You can also put lists in your own lists. The list can be made up of any number of objects, otherwise do not mother anything in yourself.
This article describes the main features and ways of describing who, as a rule, want to start programming in Python, or teach it to their child, offered by our Python course for children.
To work with list functions, you must first create the list itself. There are several ways to do this.
The main way is this list of built-in functions: with it, you can process any integration object, for example, a string.
The second way is to enumerate the elements of the list in square brackets. The first element will be at position 0, that is, if you print element 0, the print function, it will display the first weighted element.
The third way to create a list is the list generator, which is a way of assembling a new list, taking an expression for each element in the sequence. Loop-like list generators.
I suggest taking the Python for Kids course if you know all about the possibilities of a Python list.
List Methods and Operations
For lists, the main functions and methods of lists. The following shows which function can be detected using methods like this:
- list.append(x) – добавление элемента в конец списка;
- list.extend(L) – расширение списка списка, добавление в список всех элементов списка L;
- list.insert(i,x) – добавление и-элемента значения х;
- list.remove(x) – появление первого элемента в списке по значениям х. ValueError при отсутствии такового элемента;
- list.pop([i]) – вид элемента и его подтверждения. Удаление последнего элемента при отсутствии в указанном индексе;
- list.index(x, [начало [, конец]]) – подтверждение места первого элемента по значениям х, поиск начатся с начала и заканчивается в конце;
- list.count(x) – указание количества элементов по значениям х;
- list.sort([key=функция]) – сортировка списка по основным функциям;
- list.reverse() – получить список;
- list.copy() – поверхностное копирование списка;
- list.clear() – очищение списка.
List methods are aimed at changing the list itself, so the result of the execution does not need to be written to a variable. This distinguishes list methods from string methods.