#Ava Smith #smi01868 #CSCI 1133H section: 001 #Assignment 3 #================ #Purpose: To iterate through a list of lists and find strings found in all lists #Input paramaters: names, a lits containing lists containing strings of names #Return: New list, a list of names that appear in every sublist in the list names. Can be any length including an empty list #================== def busybody(names): new_list = [] counter = 0 if len(names) >= 1 and isinstance(names[0], list): for x in range(0, len(names[0])): counter = 0 for y in range(1, len(names)): if names[y].count(names[0][x]) == 1: counter +=1 if counter == len(names)-1: new_list.append(names[0][x]) if isinstance(names[0], str): return names if len(names) == 0: return [] return new_list if __name__ == "__main__": print("Pine", busybody([["Evans", "Hemsworth", "Pine", "Pratt", "Rock"], ["Ebla", "Hemsworth", "Pine", "Quinto", "Salandra"], ["Gadot", "Pascal", "Pine", "Wiig"]])) print("[]", busybody([["Andrew", "Ishika", "Meghna"], ["Amina", "Demond", "Soha"], ["Chelsey", "Joey", "Mitali"], ["David", "Dawn", "Kevin"], ["Ashlyn", "Sam", "Yasangi"]])) print("[Sam, Ben, Ted]", busybody(["Sam", "Ben", "Ted"])) print("[]", busybody([[],[]]))