Simple (?) question about print statement

TY aqteon at yahoo.com
Wed Dec 14 15:44:29 EST 2005


Hi all,

I have this little simple script:

for i in range(10):
    for j in range(5000000): pass     # Timing-delay loop
    print i

When you run it, it behaves as you would expect -- it prints 0 <pause>
on the next line prints 1 <pause> on the next line prints 2 <pause>
etc.

But if you add a comma at the end of print statement on the last line
like this:

for i in range(10):
    for j in range(5000000): pass     # Timing-delay loop
    print i,

Now it does this:

<long pause> then prints 0 1 2 3 4 5 6 7 8 9 all at once.

Why?????

How can I make it to print each numbers on the same line with pauses in
between them?

Thank you for any insight!




More information about the Python-list mailing list