:::::OUTPUT::::::
http://www.pythonchallenge.com/pc/def/274877906944.html
Redirected To
http://www.pythonchallenge.com/pc/def/map.html
More suggestion are always welcome. In case if you wish me to write about any specific scenario, please feel free to write to me or else you can Comment below.
FirstString="ABCDEFFEDCBA"
Reversed=(FirstString [::-1])
if list(FirstString) == list(Reversed):
print("It is Palindrome")
else:
print("It is not Palindrome")
Second Method:
SecondString="1234ABCCBA4321"
def palindrome(num):
return num == num[::-1]
if palindrome(SecondString) == True:
print("It is palindrome")
else:
print("It is not palindrome")
You can try to run this code on Codebunk. You can refer to my Codebunk. These are simple code which can be used in complex algorithm.
More suggestion are always welcome. In case if you wish me to write about any specific scenario, please feel free to write to me or else you can Comment below.
Above example is extended slice syntax. It works by doing [begin:end:step] - by leaving begin and end off and specifying a step of -1, it reverses a string.
Second Method:
SecondString="Second String"
def reverse(text):
if len(text) <= 1:
return text
return reverse(text[1:]) + text[0]
print(reverse(SecondString))
You can try to run this code on Codebunk. You can refer to my Codebunk. These are simple code which can be used in complex algorithm.
I am glad to add below video in my blog created by Webucator. This video explains the performance of two methods demonstrated above.
More suggestion are always welcome. In case if you wish me to write about any specific scenario, please feel free to write to me or else you can Comment below.