On 18/10/16 02:31, Zeel Solanki wrote:

> I just recently started learning python and I am having trouble figure out
> the following python problem. Can you please help me make the code for the
> the problem below:

We will help, but we won;t do the lesson for you.
You will need to wr4ite the code.

> Problem:
> Write a version of a palindrome recogniser that accepts a file name from
> the user, reads each line, and prints the line to the screen if it is a
> palindrome.

Do you know about functions yet? If so can you write a function that
recognises palindromes?

def is_palindrome(aString):...

That would be a good first step.

Secondly, can you write a function that opens a file
and prints each line?

def process_file(filename):....

Thirdly can you read a filename from the user and return it?

def get_filename:....

If so then your main program should be very easy to write.

If you are unsure about any of those three steps let us know.
But make sure you send us your code, even if it's broken.
Also send us the full text of any error messages you get.
Finally tell us which OS and Python version you are using.

Alan G
Author of the Learn to Program web site
Follow my photo-blog on Flickr at:

Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:

Reply via email to