<jupyter_start><jupyter_text>Flatten Lists within ListsGiven lists of lists, make it to a single list<jupyter_code>L = [[1,2,3],[4,5,6]]
L
# Method 1 

flat_list = []

for sublist in L: 
    print(sublist)
    for i in sublist: 
        print(i)
        flat_list.append(i)

print(flat_list)
# Method 2 - List Comprehension 
'''
[final_item for (First Loop) for (Second Loop)]
'''
flat_list = []
flat_list = [i for sublist in L for i in sublist]
print(flat_list)<jupyter_output>[1, 2, 3, 4, 5, 6]
{'fraction_non_alphanumeric': 0.1310483870967742, 'fraction_numerical': 0.028225806451612902, 'mean_word_length': 3.872549019607843, 'pattern_counts': {'":': 0, '<': 4, '<?xml version=': 0, '>': 4, 'https://': 0, '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': '1', 'dir': 'jupyter-structured-clean-dedup', 'id': '174199', 'license': 'MIT', 'n_tokens_mistral': 213, 'n_tokens_neox': 196, 'n_words': 58, 'path': '*Python_Basics/Flatten_List/Flatten_List.ipynb', 'repo_name': 'jasjung/Python', 'size': '496'}