[Tutor] Printing with no newline :(

Dave Angel d at davea.name
Sun Nov 6 12:01:29 CET 2011


On 11/06/2011 05:23 AM, Sarma Tangirala wrote:
> <SNIP> 

> python 3
> <SNIP>.
>
> Please bear with me on this, but does the following not print "end" for
> every iteration of "items"?
>
> for item in items:
>       print(item, end="")
>
>
Sure it does.  And the value of end is the empty string.  So it prints 
nothing but the item itself.

If you don't supply an argument for 'end', it also prints end, but the 
default value, which is documented as a newline. So it prints the item 
followed by a newline.  In other words, it prints each item on a 
separate line.

-- 

DaveA



More information about the Tutor mailing list