7(iii)
Write a Python program that performs the following task on a tuple:
- Create a tuple 't1' with elements (100, 110, 120, 330, 440)
- Concatenate a tuple 't2' with elements (77, 88) to 't1'
- Convert the above tuple to list.
- Append another list 'lst2' with elements [16, 26]
- Remove element in the second index.
- Insert element 40 to the list at index 5.
- Print the list.
Show SolutionHide Solution↓
t1 = (100, 110, 120, 330, 440)
t2 = (77, 88)
t1 = t1 + t2
lst1 = list(t1)
lst2 = [16, 26]
lst1.append(lst2)
lst1.pop(2)
lst1.insert(5, 40)
print("List after operations:")
print(lst1)
List after operations:
[100, 110, 330, 440, 77, 40, 88, [16, 26]]