I need your help Senpai!
How can I print 'n' number of series in a consecutive order?
Basically, I want to print 'n' numbers in series without spaces.
For example in my code,
for x in range(1, n 1):
print(x)
Output for n=5
1
2
3
4
5
But i want to get output like: 12345 (without any spaces in a single line).
Help me with this please!
CodePudding user response:
Use:
n = 10
print(*range(1,n 1), sep="")
print(*range(1,n 1))
is equivalent of print(1, 2, ..., n)
And you need sep=""
so it print doesn't displayadditional new line characters between the numbers