fork download
  1. def involved(courses, person): # result should be a dictionary of dictionaries: hexamester - a course/s
  2. result = {}
  3.  
  4. for hexamester in courses:
  5.  
  6. List = []
  7.  
  8. for course in courses[hexamester]:
  9.  
  10.  
  11. for key in courses[hexamester][course]:
  12.  
  13.  
  14.  
  15. teacher = courses[hexamester][course]['teacher']
  16.  
  17. if 'assistant' in courses[hexamester][course]:
  18. assistant = courses[hexamester][course]['assistant']
  19. if teacher == person or assistant == person:
  20.  
  21. if course not in List:
  22.  
  23. List.append(course)
  24. else:
  25. if teacher == person:
  26. if course not in List:
  27. List.append(course)
  28.  
  29. if List !=[]:
  30. result[hexamester] = List
  31. return result
Success #stdin #stdout 0.01s 7176KB
stdin
Standard input is empty
stdout
Standard output is empty