Which statement I use to print my output in one line? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Which statement I use to print my output in one line?

1,2,3,4

31st Oct 2019, 4:19 AM
Souvick Mondal
Souvick Mondal - avatar
3 Answers
+ 4
for i in range(10): print(i, end=",") Seb TheS edited👍
31st Oct 2019, 4:23 AM
Qasem
+ 2
a = 1 b = 2 c = 3 d = 4 print(a,b,c,d, sep=', ') Using end will cause this output: 1, 2, 3, 4,
31st Oct 2019, 10:18 AM
Asman-H
Asman-H - avatar
+ 1
Qasem Wrong keyword argument? print function by default adds a newline to the end what is supposed to be printed, but you can change it with a keyword argument end. print("1, ", end="") print("2, ", end="") print("3, ", end="") print("4", end="") Output: 1, 2, 3, 4 Or shorter: print(end="1, ") print(end="2, ") print(end="3, ") print(end="4")
31st Oct 2019, 5:45 AM
Seb TheS
Seb TheS - avatar