Nov-03-2019, 07:40 PM
(This post was last modified: Nov-03-2019, 07:56 PM by Gribouillis.)
I am a beginner.
The following code prints out lines that begin with From:.
If I'm using the wrong term to find a string, what is the correct one?
Yours,
Dora Smith
The following code prints out lines that begin with From:.
fhand = open('mbox-short.txt') for line in fhand: line = line.rstrip() if line (startswith('From:') : print(line)However, this line, which is supposed to only print lines containing the word Horwitz, prints every single line in the file. Why?
If I'm using the wrong term to find a string, what is the correct one?
fhand = open('mbox-short.txt') for line in fhand : if line.find('horwitz') : print(line)Thanks!
Yours,
Dora Smith