Python Syntax Practice


## Task: Use a for loop to create a list of values 0, 2, 4, …, 18
nums = []
# TODO
print(nums)

## Task: Create a new list with all non-alpha chars removed
chars = [chr(x) for x in range(50, 100)]
alpha = []
# TODO
print(alpha)


## Task: Create a new dictionary from dct that only includes those in house Gryffindor
dct = { "Potter"    : "Gryffindor", 
        "Granger"   : "Gryffindor", 
        "Malfoy"    : "Slytherin",
    	"Diggory"   : "Hufflepuff"}
gryff = {}
# TODO
print(gryff)


## Task: Create a new list from the hogwarts list of dictionaries 
##       that only includes those in house Gryffindor
hogwarts = [    {"name" : "Potter",     "house" : "Gryffindor"},
                {"name" : "Granger",    "house" : "Gryffindor"},
                {"name" : "Malfoy",     "house" : "Slytherin"},
                {"name" : "Diggory",    "house" : "Hufflepuff"}]
liGryff = []
# TODO
print(liGryff)