diff options
Diffstat (limited to 'challenge-256/sgreen/python/ch-2.py')
| -rwxr-xr-x | challenge-256/sgreen/python/ch-2.py | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/challenge-256/sgreen/python/ch-2.py b/challenge-256/sgreen/python/ch-2.py new file mode 100755 index 0000000000..051efa1d4c --- /dev/null +++ b/challenge-256/sgreen/python/ch-2.py @@ -0,0 +1,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() |
