[Tutor] Print a list in columnar format

Michael Knowles mknowles at fs.fed.us
Wed Oct 6 22:27:26 CEST 2004


Two more newbie questions regarding printing to standard output (not a text
file).  (I'm using version Python 2.3.4 on Win2000)

This is the section of code which creates my results:

    elif choice == 1:
        aou = raw_input("\nEnter AOU or species: ")
        results = [x for x in aou_species if x.lower().find(aou) != -1]
        results.sort()
        print "\nResults of ", aou, "\n", results


One (this one feels like I should know it, but...):
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


Two:
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?


Thanks in advance,
This is a very useful site
Mike


*******************************************
Mike Knowles
Information Systems Analyst
SI International
USDA, Forest Service, Rocky Mountain Research Station
2150 Centre Ave, Bldg A, Suite 361
Ft. Collins,  CO  80526
Phone:  (970) 295-5979
Fax:  (970) 295-5959
e-mail:  mknowles at fs.fed.us
*******************************************
.



More information about the Tutor mailing list