[Tutor] beginner question

Danny Yoo dyoo@hkn.eecs.berkeley.edu
Tue Dec 31 01:04:02 2002


> >How to fix this piece of code to print list elements horizontal on screen?
> >
> >###
> >list = [1,2,3,4,5]
> >
> >for i in list:
> >    print i
> >
> >###
> >
> Add a comma as follows:
>
>    for i in list:
>        print i,

Hi Djuro,

By the way, there's a section on the official Python tutorial dedicated to
printing issues here:

    http://www.python.org/doc/tut/node9.html

You might find it useful if you need more fine-grained control over
printing, since putting a trailing comma still introduces a space between
each item in your list.


Happy New Year!