Convert list to tuple Python
Ngày đăng:
21/12/2021
Trả lời:
0
Lượt xem:
129
Python Convert Tuple into ListTo convert a tuple into list in Python, call list() builtin function and pass the tuple as argument to the function. list() returns a new list generated from the items of the given tuple. Python list() builtin function In this tutorial, we will go through some examples, where we demonstrate how to convert tuple to list in Python. ExamplesConvert Tuple to ListIn the following example, we initialize a tuple and convert it to list using list(sequence). Python Program #initialize tuple aTuple = (True, 28, 'Tiger') #tuple to list aList = list(aTuple) #print list print(type(aList)) print(aList)Try OnlineOutput Convert Tuple of Integers to ListIn the following example, we initialize a tuple with all integers and convert it to a list using list(sequence). Python Program #initialize tuple aTuple = (67, 28, 41, 37) #tuple to list aList = list(aTuple) #print list print(type(aList)) print(aList)Try OnlineOutput ConclusionIn this Python Tutorial, we learned how to convert a tuple into list in Python using list(sequence), with the help of example Python programs. |