Showing posts with label String Palindrom in python. Show all posts
Showing posts with label String Palindrom in python. Show all posts

Tuesday, 20 September 2016

Program for String Palindrome in python

This is the 6th Exercise of practicepython.

Exercise

Ask the user for a string and print out whether this string is a palindrome or not. (A palindrome is a string that reads the same forwards and backwards.)


Solution:


String Palindrome in python can be done with [::-1].\


str(n) == str(n)[::-1]


[::-1 ] - this reverse the string and we are comparing with user input string.






Output:





GitHub Reference:


Github code:


https://gist.github.com/pinkpretty/989131c070cc4591a3147c803015e5fd


Happy coding !:)