Hello again, "Future Programmer" if it is the first time that you read any of my posts I recommend you to visit my old "Learning Python" posts. And without further ado, let's get into it!
Changing, Adding, and Removing Elements
Most lists you create will be dynamic, meaning you’ll build a list and then add and remove elements from it as your program runs its course.
Modifying elements in a List
The syntax for modifying an element is similar for accessing one.
Often, you’ll want to remove an item or a set of items from a list. For example, when a user decides to cancel their account on a web application you created, you’ll want to remove that user from the list of active users. You can remove an item according to its position in the list or according to its value.
If you know the position of the item you want to remove from a list, you can
use the del statement.
['jacob', 'bella', 'mark'] ['jacob', 'bella'] mark
You can add the position of the item you wanna pop by adding its position to the pop methode:
......pop(1)
This is all for today's post, hope you learned something from it, dont forget to upvote and follow me if i was of any help, if you didnt understand something just say it in the comments section, see you in the next post!
Learning Python - Part 5 - Lists - Changing, Adding, and Removing E... | Ecency