name1 = input("name2: ") name2 = input("name1: ") def popcommonchar(name1, name2): str1 = '' for s in (name1): if s not in name2: str1 += s str2 = '' for s in (name2): if s not in n1: str2 += s list = ["A", "B", "C", "D", "E", "F"] while True: if len(list) == 1: break e = (len(str1)) + (len(str2)) sum =+ e list.pop(e) print(list) popcommonchar(name1, name2) after removing the 5th item in the list, I want the program keep counting and poping/removing the 5th element. When N is the sum from length of str and str2, I want to remove the Nth item from the list ["A", "B", "C", "D", "E", "F"].
after removing F, it prompts an error, how to I fix this?