0

How to have a space between strings ???

18th Nov 2016, 9:56 AM
tony
5 Respuestas
+ 4
s = 'Hello world' s = " ".join(s[i:i+2] for i in range(0, len(s), 2)) print(s) //OUTPUT He ll o wo rl d
18th Nov 2016, 10:41 AM
Freddy Alexander Paredes
Freddy Alexander Paredes - avatar
+ 1
Explain further
18th Nov 2016, 10:22 AM
damilare lamidi
damilare lamidi - avatar
+ 1
>>> a = 'Hello' >>> b = 'world' >>> a + ' '+ b #concatanate ' ' between them 'Hello world' >>> print(a, b, sep=' ') #either use sep argument of print() Hello world
19th Nov 2016, 1:33 PM
donkeyhot
donkeyhot - avatar
0
print( "i like" + " " + "iron" + " " + "man" ) print( "i like", "iron", "man" ) print( "%s %s %s" % ( "i like", "iron", "man" ) )
18th Nov 2016, 10:59 AM
Vinicius Matté Gregory
Vinicius Matté Gregory - avatar
- 1
when i write print ("i like" + ' iron' + "Man") it comes ilikeironman NOT i like iron Man
18th Nov 2016, 10:26 AM
tony