AtCoder ABC 148 B – Strings with the Same Length Python解説
Strings with the Same Length
英小文字のみからなる長さ N の文字列 S, T が与えられます。
AtCoder Beginner Contest 「Strings with the Same Length」
S の 1 文字目、T の 1 文字目、S の 2 文字目、T の2 文字目、S の 3 文字目、…、S のN 文字目、T のN 文字目というように、 S の各文字と T の各文字を先頭から順に交互に文字を並べ、新しい文字列を作ります。この新しくできた文字列を出力してください。
与えられた文字列S,Tから一文字ずつ出力していきます。for文を使うと簡単に実装することができます。
n = int(input())
s, t = input().split()
ans = ""
for i in range(n):
ans += s[i] + t[i]
print(ans)
文字列S,Tを受け取ったらfor文を使い、一文字ずつansに足していきます。最後にansを出力して完了です。