[ create a new paste ] login | about

Link: http://codepad.org/qErRBPav    [ raw code | output | fork ]

Python, pasted on Mar 19:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
    
word1 = "google"
word2 = "goggle"

longestSegment = ""

tempSegment = ""

 
for i in range(len(word1)):
    if word1[i] == word2[i]:
        tempSegment += word1[i]
    else: tempSegment = ""

    if len(tempSegment) > len(longestSegment):
        longestSegment = tempSegment

print longestSegment


Output:
1
gle


Create a new paste based on this one


Comments: