+ 5

How do you make a code to output in a single line instead of separate lines? E.g 1 2 3 4(in python)

1st Jan 2021, 5:37 PM
Angry Student(Docvad)
Angry Student(Docvad) - avatar
4 ответов
+ 4
Using end =" " I'm not good at explaining This website explains better https://www.geeksforgeeks.org/print-without-newline-JUMP_LINK__&&__python__&&__JUMP_LINK/
1st Jan 2021, 5:42 PM
Noobmaster
Noobmaster - avatar
+ 4
for x in range(1, 5): print(x, end=" ") #Note that the value of end here is a whitespace and by default it is a newline or "\n" .
2nd Jan 2021, 1:38 AM
noteve
noteve - avatar
3rd Jan 2021, 4:19 AM
Angry Student(Docvad)
Angry Student(Docvad) - avatar
+ 2
I know ruby has both puts and print function that differ in ways they output the result of the code
1st Jan 2021, 5:39 PM
Angry Student(Docvad)
Angry Student(Docvad) - avatar