When using print with Python3, you should be aware of the sep and end options in the corner of your head. It's a very basic thing, but if you forget it, you may get unintended results.
s = 'abc'
t = 'def'
#Spaces before and after commas and tabs
print(s, ',', t) # -> abc , def
print(s, '¥t', t) # -> abc ¥t def
#If you don't want to put spaces before and after commas and tabs, specify an empty string for sep.
print(s, ',', t, sep='') # -> abc,def
print(s, '¥t', t, sep='') # -> abc¥tdef
#If you do not want to start a new line, specify an empty string for end
print(s, ',', t, sep='', end='') # -> abc,def (no line breaks)
print(s, '¥t', t, sep='', end='') # ->abc \ tdef (no line breaks)
Recommended Posts