May-08-2019, 06:56 AM
May-08-2019, 07:02 AM
(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.
May-08-2019, 07:17 AM
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
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
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