Convert list to tuple and tuple to list
examples/lists/totuple.py
planets = ['Mercury', 'Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn'] print(planets) print(planets.__class__.__name__) tpl = tuple(planets) print(tpl) print(tpl.__class__.__name__) lst = list(tpl) print(lst) print(lst.__class__.__name__)
['Mercury', 'Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn'] list ('Mercury', 'Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn') tuple ['Mercury', 'Venus', 'Earth', 'Mars', 'Jupiter', 'Saturn'] list