+ 2
Which statement I use to print my output in one line?
1,2,3,4
3 odpowiedzi
+ 4
for i in range(10):
print(i, end=",")
Seb TheS edited👍
+ 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,
+ 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")