Python Forum
Palindromes in Python - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Palindromes in Python (/thread-18167.html)



Palindromes in Python - karansingh - May-08-2019

How can I Implement palindromes in Python?


RE: Palindromes in Python - buran - May-08-2019

(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.


RE: Palindromes in Python - DeaD_EyE - May-08-2019

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-i-use-the-slice-notation-in-python