Newbie question
David Ascher
da at ski.org
Tue Jul 27 00:25:32 EDT 1999
More information about the Python-list mailing list
Tue Jul 27 00:25:32 EDT 1999
- Previous message (by thread): Newbie question
- Next message (by thread): (no subject)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
On Tue, 27 Jul 1999, Fredrik Lundh wrote: > > I'm just trying out some examples from the book Learning Python and I run > > into a exercise that is not working for me. > > It's on page 95 , exercise 4b. > > This is the answer the book has > > =========================================== > > l = [1, 2, 4, 8, 16, 32, 64] > > x = 5 > > i = 0 > > while i < len(l): > > if 2 ** x == l[i]: > > print 'at index', i > > break > > i = i + 1 > > else: > > print x , 'not found' > > ============================================ > > either you or the LP authors have messed up; > for the loop to ever terminate, the "i = i + 1" > statement should at the "while" level, not in- > side the "if" statement. It's a very understandable problem -- there is a page break before the line in question, and I don't blame Arnaldo for not having taken his ruler and counting spaces. Alas, there was little we could do in the production process to avoid all the page breaks in Python code. Sorry you wasted some time on that one, Arnaldo. python-code-wasn't-designed-for-typesetting-in-more-ways-than-one'ly y'rs, --david ascher
- Previous message (by thread): Newbie question
- Next message (by thread): (no subject)
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the Python-list mailing list