KnowledgeBoat Logo
|

Robotics & Artificial Intelligence

Write a Python program to convert a tuple into a list and a list into a tuple.

Python Tuples

3 Likes

Answer

marks_tuple = (82, 64, 91, 79, 94)
marks_list = list(marks_tuple)
print("Tuple:", marks_tuple)
print("List after conversion:", marks_list)
numbers_list = [10, 20, 30, 40, 50]
numbers_tuple = tuple(numbers_list)
print("List:", numbers_list)
print("Tuple after conversion:", numbers_tuple)

Output

Tuple: (82, 64, 91, 79, 94)
List after conversion: [82, 64, 91, 79, 94]
List: [10, 20, 30, 40, 50]
Tuple after conversion: (10, 20, 30, 40, 50)

Answered By

3 Likes


Related Questions