Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for The Longest Palindromic by bswitaj
def longest_palindromic(text):
l=0
s=""
for i in range(len(text)):
for j in range(i, len(text)+1):
b=i
e=j
n=text[b:e]
if str(n) == str(n)[::-1] and len(n)>l:
l=len(n)
s=n
print(l)
print(s)
return s
if __name__ == '__main__':
assert longest_palindromic("artrartrt") == "rtrartr", "The Longest"
assert longest_palindromic("abacada") == "aba", "The First"
assert longest_palindromic("aaaa") == "aaaa", "The A"
Oct. 17, 2017