How to print without spaces?

P

Peng Yu

Hi,

I don't want to print the space between 'a' and 'b'. Could somebody
let me know how to do it?

Regards,
Peng

$ python
Python 2.5.2 (r252:60911, May 21 2008, 10:08:24)
[GCC 4.1.2 20070626 (Red Hat 4.1.2-14)] on linux2
Type "help", "copyright", "credits" or "license" for more information.a b
 
A

Andreas Tawn

Hi,
I don't want to print the space between 'a' and 'b'. Could somebody
let me know how to do it?

Regards,
Peng

$ python
Python 2.5.2 (r252:60911, May 21 2008, 10:08:24)
[GCC 4.1.2 20070626 (Red Hat 4.1.2-14)] on linux2
Type "help", "copyright", "credits" or "license" for more information.a b

print "a" + "b"

Cheers,

Drea
 
T

Tobiah

I don't want to print the space between 'a' and 'b'. Could somebody let me
know how to do it?
a b

Since you are new, you should also be aware of:

print "%s%s" % (a, b)
 
K

koranthala

I don't want to print the space between 'a' and 'b'. Could somebody
let me know how to do it?
Regards,
Peng

$ python
Python 2.5.2 (r252:60911, May 21 2008, 10:08:24)
[GCC 4.1.2 20070626 (Red Hat 4.1.2-14)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
print "a","b"
a b

print "a" + "b"

Cheers,

Drea

What if I want to print 1 to 100 in a loop without spaces in between?
I think that is the OPs question.
 
J

Jerry Hill

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.
 
W

Wolfgang Rohdewald

What if I want to print 1 to 100 in a loop without spaces in
between? I think that is the OPs question.

arr = ['a', 'b', 'c', 'andsoon']
print ''.join(arr)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top