This is the 6th Exercise of practicepython.
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 !:)
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 !:)
No comments:
Post a Comment