Deleting values from a list

By using the del keyword, you can delete a value or a slice of list from the list.

Let's see the example of making a new team for the Civil War movie:

 >>> C_W_team = ['hulk', 'iron-man', 'Captain-America', 'Thor',"Vision"]

>>> del C_W_team[0]

>>> C_W_team

['iron-man', 'Captain-America', 'Thor', 'Vision']

>>>

>>> del C_W_team[2:4]

>>> C_W_team

['iron-man', 'Captain-America']

>>>

We deleted the first and last two values from the list in the preceding example.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.217.206.112