[Tutor] Basic question on spaces

Alan Gauld alan.gauld at btinternet.com
Tue Jul 19 09:31:03 CEST 2011


Alexander Quest wrote:

> As you can see, this is quite rudimentary; I have not discovered any special
> function that eliminates spaces yet, if such a function exits. 

There was a thread on this a week or so back.
There you will find several suggestions however, in Python 3 the
simplest is probably to use print() itself. print takes a couple of 
optional parameters, one of which defines the separator character, by 
default a space. You can specify an empty string instead and then hard 
code your spaces.

Try
 >>> help(print)

for more details.


The other options include using a format string  or string concatenation 
to create the string you want before you send it to print.

HTH,

Alan G.



More information about the Tutor mailing list