Robotics & Artificial Intelligence
Write a Python program to convert a tuple into a list and a list into a tuple.
Python Tuples
2 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
2 Likes
Related Questions
Write a Python program to display all the elements of a tuple using the for loop.
Write a Python program to create a list of first ten natural numbers. Add the square of each element to another empty list.
Write a Python program to search an element in the list.
Write a Python program to generate the square of all the elements of a list.