Run
string1 = "apples" string2 = "applications" result = "" length = min(len(string1), len(string2)) for i in range(length): if string1[i] != string2[i]: result = string1[0:i] break print(result)
Output