<jupyter_start><jupyter_text>All the IPython Notebooks in this lecture series by Dr. <NAME> are available @ **[GitHub](https://github.com/milaan9/04_Python_Functions/tree/main/002_Python_Functions_Built_in)**  Python `list()`The **`list()`** constructor returns a list in Python.**Syntax**:```pythonlist([iterable])```  `list()` ParametersThe **`list()`** constructor takes a single argument:* **iterable (optional)** - an object that could be a sequence (**[string](https://github.com/milaan9/02_Python_Datatypes/blob/main/002_Python_String.ipynb)**, **[tuples](https://github.com/milaan9/02_Python_Datatypes/blob/main/004_Python_Tuple.ipynb)**) or collection (**[set](https://github.com/milaan9/02_Python_Datatypes/blob/main/006_Python_Sets.ipynb)**, **[dictionary](https://github.com/milaan9/02_Python_Datatypes/blob/main/005_Python_Dictionary.ipynb)**) or any iterator object  Return Value from `list()`The **`list()`**  constructor returns a list.* If no parameters are passed, it returns an empty list* If iterable is passed as a parameter, it creates a list consisting of iterable's items.<jupyter_code># Example 1: Create lists from string, tuple, and list

# empty list
print(list())

# vowel string
vowel_string = 'aeiou'
print(list(vowel_string))

# vowel tuple
vowel_tuple = ('a', 'e', 'i', 'o', 'u')
print(list(vowel_tuple))

# vowel list
vowel_list = ['a', 'e', 'i', 'o', 'u']
print(list(vowel_list))
# Example 2: Create lists from set and dictionary

# vowel set
vowel_set = {'a', 'e', 'i', 'o', 'u'}
print(list(vowel_set))

# vowel dictionary
vowel_dictionary = {'a': 1, 'e': 2, 'i': 3, 'o':4, 'u':5}
print(list(vowel_dictionary))<jupyter_output>['a', 'e', 'o', 'i', 'u']
['a', 'e', 'i', 'o', 'u']<jupyter_text>> **Note:** In the case of dictionaries, the keys of the dictionary will be the items of the list. Also, the order of the elements will be random.<jupyter_code># Example 3: Create a list from an iterator object

# objects of this class are iterators
class PowTwo:
    def __init__(self, max):
        self.max = max
    
    def __iter__(self):
        self.num = 0
        return self
        
    def __next__(self):
        if(self.num >= self.max):
            raise StopIteration
        result = 2 ** self.num
        self.num += 1
        return result

pow_two = PowTwo(5)
pow_two_iter = iter(pow_two)

print(list(pow_two_iter))<jupyter_output>[1, 2, 4, 8, 16]
{'fraction_non_alphanumeric': 0.15991649269311065, 'fraction_numerical': 0.020041753653444676, 'mean_word_length': 4.6912114014251785, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 10, 'https://': 5, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '224944', 'license': 'MIT', 'n_tokens_mistral': 891, 'n_tokens_neox': 831, 'n_words': 234, 'path': '002_Python_Functions_Built_in/038_Python_list()_Function.ipynb', 'repo_name': 'ATrain951/01.python_function-milaan9', 'size': '2401'}