1# Delete Variables
2my_var = 5
3my_tuple = ('Sam', 25)
4my_dict = {'name': 'Sam', 'age': 25}
5del my_var
6del my_tuple
7del my_dict
8
9# Delete item from list
10my_list = [1, 2, 3, 4, 5, 6, 7, 8, 9]
11# deleting the third item
12del my_list[2]
13
14# Delete from dictionary
15person = { 'name': 'Sam',
16 'age': 25,
17 'profession': 'Programmer'
18}
19del person['profession']
1# the list.remove(object) method takes one argument
2# the object or element value you want to remove from the list
3# it removes the first coccurence from the list
4
5generic_list = [1, 2, 2, 2, 3, 3, 4, 5, 5, 5, 6, 8, 8, 8]
6
7generic_list.remove(1)
8
9# The Generic list will now be:
10# [2, 2, 2, 3, 3, 4, 5, 5, 5, 6, 8, 8, 8]
11
12
1liste = ['a',1,2]
2element = liste.pop()
3=> element = 2
4=> liste = ['a',1]
5liste.pop(0)
6=> element = 'a'
7=> liste = [1]
8