About printing in IDLE?

Kelly Vincent kpvincent at hotmail.com
Fri Mar 10 01:14:13 CET 2006

>Installed Python 2.4.2 on Windows XP.
>Activated IDLE.
>Loaded the following to the Edit window:
>print "hello world"
>for i in range(10):
>          print i,
>print "Done"
>It prints as: 0 1 2 3 4 5 6 7 8 9 Done
>Should not Done be printed on a new line alone?
>Thanks for any guidance.

If you don't want the "Done" to print on the same line, you need to make 
sure that in the last iteration of the loop, you don't leave the trailing 
comma after the i. This would do the trick:

for i in range(10):
    if i < 9:
        print i,
        print i
print "Done"

More information about the Python-list mailing list