[Tutor] Line in a file
Kalle Svensson
kalle@lysator.liu.se
Fri, 19 Jul 2002 01:29:29 +0200
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
[Erik Price]
> Well, I was trying to figure this one out for ya as an exercise, but
> I got stumped. So in trying answer one question, another came up.
> Can anyone tell me what's wrong here?
[...]
> >>> def printLine(fh, num): # let's make code reuseable
> ... c = 0
> ... for line in fh.xreadlines():
> ... c = c + 1
> ... if (line == num):
[...]
This should be c == num, not line == num.
Peace,
Kalle
- --
Kalle Svensson, http://www.juckapan.org/~kalle/
Student, root and saint in the Church of Emacs.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.7 (GNU/Linux)
Comment: Processed by Mailcrypt 3.5.6 <http://mailcrypt.sourceforge.net/>
iD8DBQE9N09VdNeA1787sd0RAvasAKCTHMxmlP1aQ55Edkp9g1qszHwCngCfWitf
6668ZD1/PTwNRkpvoD8+hik=
=ZxIF
-----END PGP SIGNATURE-----