Run
string1 = "banana" string2 = "banking" 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