How to Convert Tuple into List in Python?

[Pages:2]How to Convert Tuple into List in Python?

Python ? Convert Tuple into List

You can convert a Python Tuple ot Python List.

list(sequence) takes any sequence, in this case a tuple, as argument and returns a list object.

Example 1 ? Convert Python Tuple to List

In the following example, we initialize a tuple and convert it to list using list(sequence).

example.py ? Python Program

#initialize tuple aTuple = (True, 28, 'Tiger') #tuple to list aList = list(aTuple) #print list print(type(aList)) print(aList)

Output

[True, 28, 'Tiger']

Example 2 ? Convert Python Tuple to List

In the following example, we initialize a tuple with all integers and convert it to a list using list(sequence).

example.py ? Python Program

#initialize tuple aTuple = (67, 28, 41, 37) #tuple to list aList = list(aTuple) #print list print(type(aList)) print(aList)

Output

[67, 28, 41, 37]

Conclusion

In this Python Tutorial, we learned how to convert a tuple into list in Python using list(sequence), with the help of example Python programs.

Python Programming

Python Tutorial Install Python Install Anaconda Python Python HelloWorld Program Python Variables Python Variable Data Type Conversion Python Comments

Control Statements

Python If Python If Else Python While Loop Python For Loop

Python String

Python String Methods Python String Length Python String Replace Python Split String Python Count Occurrences of Sub-String Python Sort List of Strings

Functions

Python Functions

Python Collections

Python List Python Dictionary

Advanced

Python Multithreading

Useful Resources

Python Interview Questions

................
................

In order to avoid copyright disputes, this page is only a partial summary.

Google Online Preview   Download