[Tutor] Strings and file saving
Fri, 18 Aug 2000 13:03:34 -0700 (PDT)
> # read each line in the file
> for line in in_file.readlines():
> if string.find(line,'$')>= 0:
> # # "print line" works well
> # #print line
> a = line
> # # write the new file you created to the file "junk2.txt"
The error is one of indentation --- you have the
as a statement after the if block. This means that it'll try to write
that line, regardless if it found a line. Let's say that our first line
didn't have a '$'. We'll pass right by that if statement, and...
> Traceback (innermost last):
> File "today6.py", line 19, in ?
> NameError: a
Good luck to you.