[Tutor] AttributeError: 'list' object has no attribute 'find'

Alan Gauld alan.gauld at btinternet.com
Tue Dec 21 19:02:34 CET 2010


"Ben Ganzfried" <ben.ganzfried at gmail.com> wrote

> 1) Doesn't the read() file object method return the specified
> characters from the file as a string?

Yes
> 2) If #1 is correct, then why is my variable "source" being viewed 
> as
> a list as opposed to a string?

You are not using read(), you are using readlines()
which returns all of the lines in a list.

> 3) How can I change my variable "source" so that it can use the 
> 'find'
> method?

Use read()

HTH,


-- 
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/




More information about the Tutor mailing list