Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- exception_list, exception_names, final_list = [], [], []
- dict_exceptions = {}
- number_of_exception_classes = int(input())
- def get_parent_exception(checked_exception, list_exception_names, dict_exceptions, len_list_exception_names):
- if dict_exceptions[checked_exception] == ['object']:
- return False
- for i in range(len_list_exception_names):
- if list_exception_names[i] in dict_exceptions[checked_exception]:
- return True
- if len(dict_exceptions[checked_exception]) == 1:
- if get_parent_exception(dict_exceptions[checked_exception][0], list_exception_names, dict_exceptions, len_list_exception_names):
- return True
- else:
- return False
- elif len(dict_exceptions[checked_exception]) > 1:
- if __rec__(dict_exceptions[checked_exception], list_exception_names, dict_exceptions, len_list_exception_names):
- return True
- else:
- return False
- def __rec__(checked_exception, list_exception_names, dict_exceptions, len_list_exception_names):
- for i in checked_exception:
- if get_parent_exception(i, list_exception_names, dict_exceptions, len_list_exception_names):
- return True
- else:
- continue
- return False
- for i in range(number_of_exception_classes):
- inherited_classes = input().split()
- len_inherited_classes = len(inherited_classes)
- if len_inherited_classes > 2:
- for j in range(len_inherited_classes-2):
- exception_list.append(inherited_classes[2+j])
- dict_exceptions[inherited_classes[0]] = exception_list
- exception_list = []
- else:
- dict_exceptions[inherited_classes[0]] = ['object']
- number_of_exceptions_handled = int(input())
- for value in range(number_of_exceptions_handled):
- exception_names.append(input())
- if value == 0:
- continue
- elif get_parent_exception(exception_names[value], exception_names, dict_exceptions, value):
- if exception_names[value] not in final_list:
- final_list.append(exception_names[value])
- print(exception_names[value])
- else:
- continue
- else:
- continue
Add Comment
Please, Sign In to add comment