Given a dictionary that tells you a person's major, write a Python function that, given a person's name and a major, returns `True` if that person is majoring that subject, and `False` otherwise. Also return false if the student is not in the list of students.
dict = {"Abhi": "Computer Science", "Virat": "Maths"}
def name_major(name, major):
for key,val in dict.items():
if name in dict and major == dict[name]:
return True
else:
return False
print(name_major("Virat" , "Computer Science"))
Comments
Leave a comment