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.
ABC148-B
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.
n=int(input())
s,t=input().split()
for i in range(n):
print(s[i]+t[i],end="")
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=" ")
else:
print(i)
Recommended Posts