I defined a function which takes a dictionary and a key of the dictionary, then prints the first two indexes in that dictionary. I only want this function to work with dictionaries, so i embedded it in an if function. However, in this example, when i use this function on the dictionary below, it prints the second case even though the first parameter is quite clearly a dictionary.
people_d = {'Alex': (23, 178), 'Noah': (34, 189), 'Peter': (29, 175), 'John': (41, 185), 'Michelle': (35, 165)}
def people_information(d, name):
if d is type(dict):
print("Name:", name)
print("Age:", d[name][0], "y.o.")
print("Height", d[name][1], "cm")
print("-------------")
else:
print("parameter 1 is not a dictionary")
people_information(people_d, "Alex")
How do I fix this so that the if statement and the function corresponds with my dictionary?