Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def palindromeSubstring(str):
- maxLongitud = 1
- inicio = 0
- longitud = len(str)
- for i in range(longitud):
- for j in range(i, longitud):
- palindrome = True
- for k in range(0, ((j - i) // 2) + 1):
- if(str[i + k] != str[j - k]):
- palindrome = False
- if (palindrome and (j - i + 1) > maxLongitud):
- inicio = i
- maxLongitud = j - i + 1
- return str[inicio:inicio + maxLongitud]
- str = 'abracecars'
- print(palindromeSubstring(str))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement