0
Why following code is raising error?
def palindrome(c) : return c == c[ :: -1] if yes : print(len(s)-1) else: print(len(s)) s=input("enter the string:") print(palindrome(s))
3 Réponses
+ 2
It is not raising any error...
If you are talking about wrong output then it might be because you are comparing Capital letter with smaller ones...
In your code
Racecar == racecaR
Will be false, while it is a palindrome
to fix this
return c.lower() == c[::-1].lower()
And everything after return will not be executed so there is no point in adding something after it...
You can see the edited code.
https://code.sololearn.com/c9BQB12IhXya/?ref=app
+ 2
Amey Godse If you want the code to print if else, then you have to put return at end.
Nothing after the return is executed.
I have fixed it in the code given...
0
I am asking why code is not printing if and else condition output ?