+ 2
Why is there a space in the output without adding the space myself?
Hi all, Can someone explain why the following code... ages = {"Tonja":45, "John":46} print("John is",ages["John"]) print("Tonja is",ages["Tonja"]) Gives the following result... John is 46 Tonja is 45 I write the following code: print("John is"..., instead of print("John is "..., so I expect no space between "is" and the age. Why is there a space anyway in the output? Thanks in advance
4 Answers
+ 3
Use
print("text1", "text2", sep = x, end = y)
to control the separating string,
where x separates text1 and text2,
where y is printed after printing all the text parameters.
x is ' ' by default.
y is '\n' by default.
+ 2
I think it does that automatically, since if the number were negative, then that space would be taken up by the negative sign.
+ 2
As far as I know, it is because of the "coma", just change it for a "plus" sign
0
Hi Samuel and Keto. Thank you both for your replies.