Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Palindromes in Python
#1
How can I Implement palindromes in Python?
Reply
#2
(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.
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply
#3
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
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
Question Help with Python - Palindromes SantiagoPB 4 2,261 Apr-04-2021, 06:09 PM
Last Post: buran
  What are Palindromes in Python? HarshaliPatel 5 3,719 Dec-11-2018, 07:24 AM
Last Post: himanibansal

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020