DEV Community

Discussion on: How to write for loops horizontally in python?

Collapse
 
rhymes profile image
rhymes

Oh I get it, you need to tell print() which ending character it needs to print, it defaults to newline:

>>> for i in range(1, 11):
...     print(i)
...
1
2
3
4
5
6
7
8
9
10
>>> for i in range(1, 11):
...     print(i, end=" ")
...
1 2 3 4 5 6 7 8 9 10
Enter fullscreen mode Exit fullscreen mode
Thread Thread
 
theoretician profile image
theoretician

Awesome! it was very helpful :)

Thread Thread
 
anisrm profile image
Anis

How to do that in Javascript?