aboutsummaryrefslogtreecommitdiff
path: root/challenge-256/sgreen/python/ch-2.py
blob: 051efa1d4c2bcb61622aa27caa39032553cd5252 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#!/usr/bin/env python3

import sys
from itertools import zip_longest


def merge_strings(words: list) -> str:
    """Merge strings together by taking the first character from each word,
      then the second, and so on.

    Args:
        words (list): A list of words

    Returns:
        str: The merged string
    """
    return ''.join(''.join(s) for s in zip_longest(*words, fillvalue=''))


def main():
    result = merge_strings(sys.argv[1:])
    print(result)


if __name__ == '__main__':
    main()