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

Опубликовано: 03 Май 2022
на канале: Programming With Nick
331
21

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”.


Смотрите видео Lists - Add Item, Remove Item, Sort, Length - Python for Absolute Beginners Course онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь Programming With Nick 03 Май 2022, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 331 раз и оно понравилось 21 людям.