class Solution:
def mergeAlternately(self, word1: str, word2: str) -> str:
max_len = max(len(word1), len(word2))
word1, word2 = list(word1), list(word2)
answer = ''
for i in range(max_len):
if len(word1) > i:
answer += word1[i]
if len(word2) > i:
answer += word2[i]
return answer
Python
복사