+ 2
How to print in python without trailing new line. For instance printing "1,2,3,4,......,n" using for loop
4 ответов
+ 3
n=10
for i in range(n):
print(i, end=' ')
end signifies the endline character, the default is '\n' which is a newline
by supplying a different one you can control the output
you can change it to anything else
print(i, end=' ^_^ ')
0
for I in range(4):
print(I)
0
@DerpyOmnister. the output for your code is
0
1
2
3
But I need 0,1,2,3
0
print(','.join(str(x) for x in range(10)))