+ 1
Why the code has Error ?
Why I receive error on this code ? In first step I find reverse of a string then check whether is palindrome or not ... ? https://code.sololearn.com/c7n5d2ImzjD2/?ref=app
2 Answers
+ 9
The first error you get when you run the code is an IndentationError because the 'else' should line up with the previous 'if'.
Once you fix that, you get a SyntaxError because you use 'return' outside the function.
To make the function do what you want, make the last line
'return Rev == s'
rather than just
'return Rev'
and then delete everything after that.
Then when you run it you will get 'No ouput.' because there is no input and you haven't called the function.
To test it, add this line and run the code:
print(reverse_str_v1('abba'))
p.s. I agree with cHampsonR about not starting variable names with capitals :)
+ 3
First, you never called the function that contains most of the code. Second off, you only declared he variables in the function, so they cannot be used outside of it. Another thing, just personal preference, don't capitalize variable names (this is just personal preference, you don't have to agree).