Python List list() Method
The Python list() method is used to convert a tuple or string into a list.
Note: Tuple and list are very similar, the difference is that the element value of tuple cannot be modified, tuple is placed in brackets, list is placed in square brackets.
Python List list() Syntax
Syntax of the list() method.
list( seq )
Python List list() Parameters
- seq : The tuple or string to be converted to a list.
Python List list() Return Value
Return to the list.
Python List list() Example#1
The following example demonstrates the use of the list() function.
#!/usr/bin/python3
aTuple = (123, 'apidemos', 'deepinout', 'com')
list1 = list(aTuple)
print ("List elements : ", list1)
str="Hello World"
list2=list(str)
print ("List elements : ", list2)
Output: