[Tutor] newbie 'while' question

Zak Arntson zak@harlekin-maus.com
Mon Jun 30 14:02:02 2003


> Trying to do it with 'while', I've only managed to get it to print
> through to the last character, where it loops and continues to print the
> last character until escaped.  Someone willing to point me in the right
> direction?

How are you iterating? There are several ways to do this. One method
involves the string splitting stuff:

>>> a = 'frog'
>>> a[2]
o
>>> a[1:3]
rog
>>> a[:2]
fr

---
Zak Arntson
www.harlekin-maus.com - Games - Lots of 'em