print and softspace in python

Bruno Desthuilliers bruno.42.desthuilliers at
Thu Mar 15 12:36:19 CET 2007

Phoe6 a écrit :
> print and softspace in python
> In python, whenever you use >>>print statement

Drop the '>>>' part. It's just the default Python shell prompt.

> it will append a
> newline by default. If you don't want newline to be appended, you got
> use a comma at the end (>>>print 10,)
> When, you have a list of characters and want them to be printed
> together a string using a for loop,

Why would one use a for loop to do so ? This is inefficient (even in C - 
it's mostly a system limitation). If you have a list of characters 
(actually, a list of one-character strings - there's no 'char' type in 
Python) and want to print it as a string, then first turn that list into 
a string, then print it:

 >>> list1=['a','b','c']
 >>> print "".join(list1)


More information about the Python-list mailing list