[Tutor] Print a list in columnar format

R. Alan Monroe amonroe at columbus.rr.com
Thu Oct 7 00:38:04 CEST 2004


> How do I print/display a list in column format?  For example, my results
> are displayed as in the Python Shell window:

>       ['04550 Dusky-capped Flycatcher \n', '24550 White-breasted
> Wood-Swallow \n']

> but I would like:

>       04550 Dusky-capped Flycatcher
>       24550 White-breasted Wood-Swallow

Here's one way...

for x in results:
    print x


> Some of my results may have more species than can fit on my cmd window.  Is
> there a way to tell Python to stop printing at say 20 species and wait for
> the user to hit the Enter key before printing the next 20 species, etc?

Depending on the program, you can cheat and pipe it to more. That's
only good for programs where the user doesn't need to key in any data,
though.

Alan



More information about the Tutor mailing list