Is there any way to print output in Python without a space? | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
+ 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!

6th Feb 2020, 6:33 PM
Itzz Me
Itzz Me - avatar
6 ответов
+ 3
for l in ytox: print ("". join(l))
6th Feb 2020, 6:58 PM
Oma Falk
Oma Falk - avatar
+ 5
could you explain please? Something is telling me that this is not what u wanted 🤔 Jan Markus are u asleep?
6th Feb 2020, 6:41 PM
Oma Falk
Oma Falk - avatar
+ 5
print ('####\n' * 4)
6th Feb 2020, 6:53 PM
Sebastian Keßler
Sebastian Keßler - avatar
6th Feb 2020, 6:39 PM
Oma Falk
Oma Falk - avatar
+ 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.
6th Feb 2020, 7:45 PM
HonFu
HonFu - avatar
+ 1
^read edit, thanks!
6th Feb 2020, 6:55 PM
Itzz Me
Itzz Me - avatar