Concatenation Operator + Or ,
var1 = 'abc' var2 = 'xyz' print('literal' + var1 + var2) # literalabcxyz print('literal', var1, var2) # literal abc xyz ... except for automatic spaces with ',' whats the differe
Solution 1:
Passing strings as arguments to print joins them with the 'sep' keyword. Default is ' ' (space).
Separator keyword is Python 3.x only. Before that the separator is always a space, except in 2.5(?) and up where you can from __future__ import print_function
or something like that.
>>>print('one', 'two') # default ' '
one two
>>>print('one', 'two', sep=' and a ')
one and a two
>>>' '.join(['one', 'two'])
one two
>>>print('one' + 'two')
onetwo
Post a Comment for "Concatenation Operator + Or ,"