[PYTHON] [At Coder] Output method

I have summarized the problems that can shorten the code by devising the output method. When I didn't know how to do this, I used to make a list of everything and make it a "". Join (list), which was annoying.


The problem itself is simple, but if you devise an output method, the code will be shorter. If you add end = "" to the argument of print (), a line break will not occur.


for i in range(n):

ABC137-B In the if statement, a line break is inserted after the last character (it can be passed without it, but let's insert it for the correctness of the code).

k,x=map(int, input().split())

for i in range(x-k+1,x+k):
    if i<x+k-1:
        print(i,end=" ")

Recommended Posts

[At Coder] Output method
At Coder (2020/09/08)
Fill at Coder
At Coder # 1 at midnight
[At Coder] ABC128B --Guidebook
[At Coder] Acing C-XYZ Triplets
[Python] Competitive template [At Coder]
Learning method output for LPIC acquisition
[At Coder] ABC085C --Otoshidama's Python answer
fish erases single-character newline output at prompt