LearnPy Hub
← Strings problems
Hard

Longest Palindrome Inside

Read a word (up to 200 letters) and print its longest substring that reads the same backwards. If several have the same length, print the one that starts first. Try expanding around each centre.

Input

One word.

Output

One word.

Sample 1

Input
babad
Output
bab

Sample 2

Input
cbbd
Output
bb
solution.py
Output appears here
Longest Palindrome Inside · Python practice problem · LearnPy Hub