Python Forum

Full Version: Palindromes in Python
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
How can I Implement palindromes in Python?
(May-08-2019, 06:56 AM)karansingh Wrote: [ -> ]How can I Implement palindromes in Python?
what exactly do you want to achieve?
and a bit of friendly advice - when you ask questions, better take part in the following discussion and acknowledge the answers you get.
A palindrome is a word, which is reversed order, the same word.

Example:
Anna == annA

When you write the program, you need first to lower or upper all chars.
Otherwise there will be differences in upper/lower case, if you reverse the word.

What you need, is just the original word -> lower -> reverse (a new string) > compare it
To reverse a string, you can use the square brackets. There is also a built-in function reversed,
but this function returns a reversed object. This is more interesting for sequences/collections, but not for strings.
Just look here: https://www.oreilly.com/learning/how-do-...-in-python