Write a program to perform below operations on tuple:
- Create a tuple with different data types.
- Print tuple items.
- Convert tuple into a list.
- Remove data items from a list.
- Convert list into a tuple.
- Print tuple items.
Code
# create tuple with different data typest1 = (1, 2, 3, 4, 5, 6, 7, 8, 9, 10)t2 = ('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j')# print tupleprint(t1)print(t2)# convert tuple to listl1 = list(t1)print("Tuple to list: ", l1)# remove element from listl1.remove(5)print("List after removing element (5 removed): ", l1)# convert list to tuplet3 = tuple(l1)print("List to tuple: ", t3)# print tupleprint(t3)
0 Comments
Post a Comment