6 Replies - 327 Views - Last Post: 25 April 2013 - 03:48 PM Rate Topic: -----

#1 Brilliantwarrior  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 05-December 12

Where to begin (detecting palindromes)

Posted 23 April 2013 - 12:45 PM

I'm currently learning Python 3 on a tutorial site, which introduces topics, and gives you a task to apply what you've learned. I have a task to do, but I don't know where to start.
A pointer in the right direction would be greatly appreciated
.

Task:
A palindrome is a word which is spelled the same forwards as backwards. For example, the word
racecar
is a palindrome: the first and last letters are the same ®, the second and second-last letters are the same (a), etc. Write a function isPalindrome(S) which takes a string S as input, and returns True if the string is a palindrome, and False otherwise.


Is This A Good Question/Topic? 0
  • +

Replies To: Where to begin (detecting palindromes)

#2 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 8964
  • View blog
  • Posts: 33,624
  • Joined: 12-June 08

Re: Where to begin (detecting palindromes)

Posted 23 April 2013 - 12:51 PM

You don't know where to start? Do you know how to create a blank project? How about breaking down the required task.. say writing a function that has a parameter and a return value?
Was This Post Helpful? 0
  • +
  • -

#3 jon.kiparsky  Icon User is online

  • Pancakes!
  • member icon


Reputation: 7578
  • View blog
  • Posts: 12,749
  • Joined: 19-March 11

Re: Where to begin (detecting palindromes)

Posted 23 April 2013 - 12:56 PM

There are a number of ways to do this. You should be able to come up with three or four just by thinking about what it means for a string to be a palindrome. So start by thinking of ways you can attack the problem. There are lots of methods of the str class, and you can easily convert strings to lists, so you have all of the list methods as well.

View PostBrilliantwarrior, on 23 April 2013 - 02:45 PM, said:

I'm currently learning Python 3 on a tutorial site, which introduces topics, and gives you a task to apply what you've learned.


So if you want to get the benefit of this task, you're going to have to apply what you've learned!
Was This Post Helpful? 2
  • +
  • -

#4 Brilliantwarrior  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 05-December 12

Re: Where to begin (detecting palindromes)

Posted 23 April 2013 - 01:01 PM

View Postmodi123_1, on 23 April 2013 - 03:51 PM, said:

You don't know where to start? Do you know how to create a blank project? How about breaking down the required task.. say writing a function that has a parameter and a return value?

I need to write a program which compares the characters of a string from beginning to end, when the string is spelled backwards and frontwards. If all of the characters from beginning to end; backwards, and frontwards are the same, it should return "true", otherwise return "false". So the word: "racecar" should return true, because it's characters are the same spelled forwards or backwards.
Was This Post Helpful? 0
  • +
  • -

#5 modi123_1  Icon User is offline

  • Suitor #2
  • member icon



Reputation: 8964
  • View blog
  • Posts: 33,624
  • Joined: 12-June 08

Re: Where to begin (detecting palindromes)

Posted 23 April 2013 - 01:06 PM

Oh I am well aware what the aim of the project is, but I don't know what "where to start" means. So let's rewind - can you make a python project?
Was This Post Helpful? 0
  • +
  • -

#6 jon.kiparsky  Icon User is online

  • Pancakes!
  • member icon


Reputation: 7578
  • View blog
  • Posts: 12,749
  • Joined: 19-March 11

Re: Where to begin (detecting palindromes)

Posted 23 April 2013 - 01:08 PM

Yes, that's a good statement of the problem. So how do you think you'd go about this?
Was This Post Helpful? 0
  • +
  • -

#7 alexr1090  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 44
  • View blog
  • Posts: 124
  • Joined: 08-May 11

Re: Where to begin (detecting palindromes)

Posted 25 April 2013 - 03:48 PM

this is easy.
def isItAPal(s): 
    CENSORED


glad I could help.

This post has been edited by jon.kiparsky: 25 April 2013 - 03:58 PM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1