How to print without spaces?

Jerry Hill malaclypse2 at gmail.com
Fri Sep 18 16:26:31 EDT 2009


On Fri, Sep 18, 2009 at 4:16 PM, koranthala <koranthala at gmail.com> wrote:
> What if I want to print 1 to 100 in a loop without spaces in between?
> I think that is the OPs question.

In that case I would skip using print entirely, and use something like this:

import sys
for i in xrange(100):
    sys.stdout.write(str(i))
sys.stdout.write('\n')

That allows you to bypass any of the behavior of the print builtin
that you don't want.

-- 
Jerry



More information about the Python-list mailing list