[Tutor] Hi everyone

W W srilyk at gmail.com
Thu May 21 13:23:31 CEST 2009


On Thu, May 21, 2009 at 2:42 AM, spir <denis.spir at free.fr> wrote:

> <snip>
>    while word:
>         position = random.randrange(len(word))
>        jumble += word[position]
>        word = word[:position] + word[(position + 1):]
>

Something that many of us use for debugging, and is also useful for
comprehension is a simple print statement. If you were to convert the loop
to this:

while word:
        position = random.randrange(len(word))
       jumble += word[position]
       word = word[:position] + word[(position + 1):]
       print jumble
       print word
       # Optional - for further understanding
       print word[:position]
       print word[(position+1):]

you would basically see what Denis wrote - only every step through the loop.

HTH,
Wayne

p.s. - When you start graphical programming, I'd look at pyglet or pygame.
Although to really understand event driven programming, it really helped me
to start writing programs with Tkinter. YMMV
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20090521/983bf308/attachment.htm>


More information about the Tutor mailing list