+ 1
Why is there spaces before love and Python in the output of this code?
2 Réponses
+ 3
Comma-separated items automatically get spaced.
print( "{}\n{}\n{}".format("but", "not", "this") )
print("or\n", "this\n", sep="")
print("or", "this", sep="\n")
+ 1
So commas are the reason. So I think if we write the code like this :
print ("I\nlove\nPython\n")
this will solve the problem. and in fact it did here. But I wonder if there are casses that this won't help. any ideas?