+ 10

[PythonEdu] Recursive palindrome checker

Another example of using recursion, as the algorithm base. Most tutorials mention 'factorial' or 'power of' as examples of recursion. But this can also be used in text-based problematics. The code goes recursively inside a string, by checking for equality of its first and last character, if so, assumes the same string stripped of the first and the last characters for the next iteration... and so on. Note: one-char and empty strings are palindromes by definition :) https://code.sololearn.com/cgtlGQC2E04W/

1st Apr 2017, 8:27 AM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
4 Answers
+ 11
Hmm...That's recursive power! Great! Why don't you first take an input from user and then true or false? Thanks @Kuba
1st Apr 2017, 8:31 AM
Dev
Dev - avatar
+ 7
Of course that is only for education purposes. There is actually no point in using recursion for palindrome checkup in Python. A much simpler method: https://code.sololearn.com/cR4DVjNP4rXd/?ref=app
1st Apr 2017, 8:30 AM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 5
Of course it can be done. But under SL it works crappy :)
1st Apr 2017, 10:00 AM
Kuba Siekierzyński
Kuba Siekierzyński - avatar
+ 2
Hi kuba, can you please review my code on checking palindromes https://code.sololearn.com/cm52O60tK6yU/?ref=app
26th Apr 2018, 4:45 AM
Lokesh Kumar
Lokesh Kumar - avatar