Newbie question

Arnaldo javanet at sinbad.net
Mon Jul 26 21:41:03 EDT 1999


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'
============================================

 When I run this , python hangs. When I do Ctrl-c , this is what I get
Traceback (inntermost last):
    File "powera.py, line 5, in ?
        if 2 ** x  == l[i]:

What am I doing wrong?
Thanks I lot







More information about the Python-list mailing list