+ 1

Why isn't it working properly??

a = input() for k in range(len(a)+1): if a[:k] == a[k::-1]: print(a[k::-1])

7th Aug 2021, 5:04 PM
Shahir
Shahir - avatar
3 odpowiedzi
+ 4
len(a)-1
7th Aug 2021, 5:14 PM
Oma Falk
Oma Falk - avatar
+ 1
Shahir How about this one? :- a = input() for i in range(len(a) - 1, -1, -1): if a[:i+1] == a[i::-1]: print(a[:i+1]) break # Hope this
7th Aug 2021, 7:33 PM
Calvin Thomas
Calvin Thomas - avatar
0
Given a string s, return the longest palindromic substring in s Input: s = "babad" Output: "bab" Note: "aba" is also a valid answer
7th Aug 2021, 5:32 PM
Shahir
Shahir - avatar