How do I handle cases with numbers or the other cases?
I am doing a code coach, and I have passed half the cases, but there seem to be cases with digits, as outlined in the brief. Here's my attempt. str_input = input().split(" ") def mutate(x): start = 0 end = 1 while start < len(x): i = 0 while i < len(x): yield x[start:end] end += 1 i += 1 start += 1 mutations = [] for i in str_input: for j in mutate(i): mutations.append(j) commons = [] for i in mutations: common = set([x for x in str_input if(i in x)]) if len(common) == len(str_input) and len(i) > 2: commons.append(i) res = [x for x in commons if commons.count(x) > 1] res = list(sorted(res, key=str.lower)) res = set(res) res = list(res) if len(res) > 1: res = list(sorted(res, key=len)) res = list(sorted(res, key=str.lower)) print(res[0]) else: print(res[0])