Task
The included code stub will read an integer, n, from STDIN.
Without using any string methods, try to print the following:
123...n
Note that "" represents the consecutive values in between.
Example
n = 5
Print the string 12345.
Solution:
n = int(input()) for n in range(1,n+1): print(n,end = '') |
Note:
This Code is Verified by all Test Cases.If any error occurs then Comment correct code Below in comment box.
Disclaimer:-
The above hole problem statement is given by hackerrank.com, but the solution is generated by the CodexRitik . if any of the query regarding this post or website fill the following contact form Thank You.
if __name__ == '__main__':
ReplyDeleten = int(input())
for i in range(n):
print(str(i+1),end="")
This will also works
You are right.Thanks for feedback.
Deletemy code is not working at end it's showing undefined variable.
ReplyDeletecan you send that code here?
Deletewhy have we used end here why not anything else ??
ReplyDeleteBecause it prevents spaces between strings
Delete