GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing www.geeksforgeeks.org — Python list() Function - GeeksforGeeks Python list() FunctionLast Updated : 27 May, 2026 list() function is used to create a list from iterable objects such as strings, tuples, sets and dictionaries. It converts each element of the iterable into a separate item in the list.
Output ['P', 'y', 't', 'h', 'o', 'n'] Explanation: list(s) converts each character of the string "Python" into separate elements of a list. Syntax
Parameters: iterable (optional) - an object that can be iterated over, such as a string, tuple, set or dictionary. Returns: A new list containing elements from the iterable. If no argument is provided, it returns an empty list []. ExamplesExample 1: In this example, a tuple containing numbers is converted into a list using the list() function.
Output [10, 20, 30, 40] Explanation: list(tup) converts all elements of the tuple into a list. Example 2: Here, the list() function is used to convert dictionary keys into a list.
Output ['A', 'B', 'C'] Explanation: When a dictionary is passed to list(), only the keys are added to the list. Example 3: This example takes input from the user and converts each character into a list element.
Output
Explanation: list(input()) converts the entered string into a list of individual characters. Comment Explore |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |