Lists - Add Item, Remove Item, Sort, Length - Python for Absolute Beginners Course

preview_player
Показать описание
In this Python tutorial we are going to learn the following things:
How to modify a Python List
How to add and element to a Python list
How to remove an element from a Python list
How to sort a Python list
How to find the length of a list

Now that we know the basics of Lists in Python let’s see some cool things, we can do with them.
I have created a fruits list that contains three String items. The words, “Apple”, “Orange”, “Banana”
Let's say we want to modify an item of the list. Let's say we want the third item of the list to be the word “Avocado” instead of “Banana”. How can we do that?
Simple. Remember that we have to index to help us. Banana, the third item of the list has an index of 2. So, we type:
fruits[2] = “Avocado”
With this command, we tell the computer. Go to the memory and you will find a list named fruits. Go to the slot with index 2, and replace the item that exists there with the item “Avocado”.
Рекомендации по теме
Комментарии
Автор

It will help you memorize all the stuff we discuss in this lesson.

programmingwithnick
join shbcf.ru