+ 2
Is there any way to print output in Python without a space?
Hello! I have been learning Python, and I have a problem. Iām testing out a location code in Python. The expected output was: #### #### #### #### But, because of āprint()ā automatically escaping, I cannot make it. Any solutions? edit: Like I said, iām testing location code in Python. for clarification, coordinate stuff. I stored the coordinates like this: ytox = [[#,#,#,#],[#,#,#,#],[#,#,#,#],[#,#,#,#]] Thank you! edit 2: Thanks, Oma Falk!
6 Answers
+ 3
for l in ytox:
print ("". join(l))
+ 5
could you explain please?
Something is telling me that this is not what u wanted š¤
Jan Markus are u asleep?
+ 5
print ('####\n' * 4)
+ 3
You can add two arguments to the print function: sep (separator) and end.
They default to ' ' and '\n', space and newline, because you use that quite often.
However, you can easily change it:
print(a, b, c, sep='', end=' ') for example would print the three variables next to each other, and the line would not end with 'return', but with a space.
Can be any other string you could think of.
+ 1
^read edit, thanks!