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.
Where to begin (detecting palindromes)
Page 1 of 16 Replies - 645 Views - Last Post: 25 April 2013 - 03:48 PM
Replies To: Where to begin (detecting palindromes)
#2
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?
#3
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.
So if you want to get the benefit of this task, you're going to have to apply what you've learned!
Brilliantwarrior, 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!
#4
Re: Where to begin (detecting palindromes)
Posted 23 April 2013 - 01:01 PM
modi123_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.
#5
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?
#6
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?
#7
Re: Where to begin (detecting palindromes)
Posted 25 April 2013 - 03:48 PM
this is easy.
glad I could help.
def isItAPal(s): CENSORED
glad I could help.
This post has been edited by jon.kiparsky: 25 April 2013 - 03:58 PM
Page 1 of 1