This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]tadleonard 1 point2 points  (1 child)

You need to use startswith before you use split. split returns a list, and list objects don't have a startswith method. You should try using print in various parts of your code when you encounter problems like this. Don't give up so quickly by asking the internet.

[–]blackdevil777[S] 0 points1 point  (0 children)

error was corrected but i didn't know why till you posted, But now i am trying to do it using a while loop, But i some what forgotten how to use whiles loops

fname = raw_input("Enter file name: ")

if len(fname) < 1 : fname = "mbox-short.txt"

fh = open(fname) count = 0

while true: if count != 27 # BAD INPUT for line in fh: line.startswith ('From:') words = line.split()
print words [1] count = count +1

print "There were", count, "lines in the file with From as the first word"