In [1]:
## Original List Comprehension Exercise -- 9/18/19
cats = ["Michael", "Kevin", "Stanley", "Angela", "Dwight", "Phyllis"]
excited_cats = [cat.upper() for cat in cats]
print(excited_cats)
girl_cats = [cat for cat in cats if cat[-1] is 'a' or cat[-1] is 's']
print(girl_cats)
['MICHAEL', 'KEVIN', 'STANLEY', 'ANGELA', 'DWIGHT', 'PHYLLIS']
['Angela', 'Phyllis']
In [5]:
## Iterables Exercise -- 10/14/19
cats = ["Michael", "Kevin", "Stanley", "Angela", "Dwight", "Phyllis"]
cats_with_i = [cat for cat in cats if 'i']
In [3]:
cats_with_i
Out[3]:
['Michael', 'Kevin', 'Dwight', 'Phyllis']
In [ ]: