<jupyter_start><jupyter_text>List ComprehensionList comprehension provide a concise way to create lists. It consists of brackets containing an expression followed by a for clause, then zero or more for or if clause. The expressions can be anything , meaning you can put in all kinds of objects in lists.<jupyter_code>lst1=[]
def lst_square(lst):
    for i in lst:
        lst1.append(i*i)
    return lst1
lst_square([1,2,3,4,5,6,7])
# we use list comprehension instead of above
lst = [1,2,3,4,5,6,7]

[i*i for i in lst ]
lst2 = [i*i for i in lst]
print(lst2)
# reducing the number of code
# much faster
lst3 = [i*i for i in lst if i%2==0]
print(lst3)
lst4 = [i*i for i in lst if i%2!=0]
print(lst4)<jupyter_output>[1, 9, 25, 49]
{'fraction_non_alphanumeric': 0.10714285714285714, 'fraction_numerical': 0.04532967032967033, 'mean_word_length': 4.4, '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': '266649', 'license': 'Apache-2.0', 'n_tokens_mistral': 285, 'n_tokens_neox': 270, 'n_words': 105, 'path': 'pypractise13.ipynb', 'repo_name': 'pemtash/pypractise1', 'size': '728'}