python drop in tuple

Solutions on MaxInterview for python drop in tuple by the best coders in the world

showing results for - "python drop in tuple"
Jaylinn
06 Nov 2019
1my_tuple = (10, 20, 30, 40, 50)
2
3# converting the tuple to the list
4my_list = list(my_tuple)
5print my_list  # output: [10, 20, 30, 40, 50]
6
7# Here i wanna delete second element "20"
8my_list.pop(1) # output: [10, 30, 40, 50]
9# As you aware that pop(1) indicates second position
10
11# Here i wanna remove the element "50"
12my_list.remove(50) # output: [10, 30, 40]
13
14# again converting the my_list back to my_tuple
15my_tuple = tuple(my_list)
16
17
18print my_tuple # output: (10, 30, 40)
19