<jupyter_start><jupyter_text>[ for  in  if ] You can also combine map and filter operations by chaining them together, or with a single list comprehension.<jupyter_code>things = [3, 4, 6, 7, 0, 1]
#chaining together filter and map:
# first, filter to keep only the even numbers
# double each of them
print(list(map(lambda x: x*2, filter(lambda y: y % 2 == 0, things))))

# equivalent version using list comprehension
print([x*2 for x in things if x % 2 == 0])<jupyter_output>[8, 12, 0]
[8, 12, 0]<jupyter_text>Write code to assign to the variable compri all the values of the key name in any of the sub-dictionaries in the dictionary tester. Do this using a list comprehension.<jupyter_code>tester = {'info': [{"name": "Lauren", 'class standing': 'Junior', 'major': "Information Science"},{'name': 'Ayo', 'class standing': "Bachelor's", 'major': 'Information Science'}, {'name': 'Kathryn', 'class standing': 'Senior', 'major': 'Sociology'}, {'name': 'Nick', 'class standing': 'Junior', 'major': 'Computer Science'}, {'name': 'Gladys', 'class standing': 'Sophomore', 'major': 'History'}, {'name': 'Adam', 'major': 'Violin Performance', 'class standing': 'Senior'}]}

inner_test = tester['info']
# print(inner_test)
import json
print(json.dumps(inner_test,indent = 4))

compri = [a['name'] for a in inner_test]

print(compri)<jupyter_output>[
    {
        "name": "Lauren",
        "class standing": "Junior",
        "major": "Information Science"
    },
    {
        "name": "Ayo",
        "class standing": "Bachelor's",
        "major": "Information Science"
    },
    {
        "name": "Kathryn",
        "class standing": "Senior",
        "major": "Sociology"
    },
    {
        "name": "Nick",
        "class standing": "Junior",
        "major": "Computer Science"
    },
    {
        "name": "Gladys",
        "class standing": "Sophomore",
        "major": "History"
    },
    {
        "name": "Adam",
        "major": "Violin Performance",
        "class standing": "Senior"
    }
]
['Lauren', 'Ayo', 'Kathryn', 'Nick', 'Gladys', 'Adam']
{'fraction_non_alphanumeric': 0.17518248175182483, 'fraction_numerical': 0.010218978102189781, 'mean_word_length': 3.630630630630631, 'pattern_counts': {'":': 19, '<': 7, '<?xml version=': 0, '>': 7, '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': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '328296', 'license': 'MIT', 'n_tokens_mistral': 709, 'n_tokens_neox': 662, 'n_words': 214, 'path': 'Py3_programing_Seires/Data_Collection_and_Processing/List_Comprehensions.ipynb', 'repo_name': 'fengjings/Coursera', 'size': '2055'}