From 381421f1e2f26e23ce56e269227471a30affc53c Mon Sep 17 00:00:00 2001 From: Mohammad S Anwar Date: Sun, 28 Jan 2024 18:20:30 +0000 Subject: - Added solutions by Steven Wilson. --- challenge-253/steven-wilson/python/ch-01.py | 18 ------------------ challenge-253/steven-wilson/python/ch-1.py | 18 ++++++++++++++++++ 2 files changed, 18 insertions(+), 18 deletions(-) delete mode 100644 challenge-253/steven-wilson/python/ch-01.py create mode 100644 challenge-253/steven-wilson/python/ch-1.py diff --git a/challenge-253/steven-wilson/python/ch-01.py b/challenge-253/steven-wilson/python/ch-01.py deleted file mode 100644 index d6f4bf74ca..0000000000 --- a/challenge-253/steven-wilson/python/ch-01.py +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env python3 - - -def split_strings(*strings, separator=","): - ''' Given an array of strings and a character separator. - Return all words separated by the given character excluding empty strings - >>> split_strings("one.two.three","four.five","six", separator=".") - ['one', 'two', 'three', 'four', 'five', 'six'] - >>> split_strings("$perl$$", "$$raku$", separator="$") - ['perl', 'raku'] - ''' - return [word for string in strings for word in string.split(separator) if word != ""] - - -if __name__ == "__main__": - import doctest - - doctest.testmod() diff --git a/challenge-253/steven-wilson/python/ch-1.py b/challenge-253/steven-wilson/python/ch-1.py new file mode 100644 index 0000000000..d6f4bf74ca --- /dev/null +++ b/challenge-253/steven-wilson/python/ch-1.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python3 + + +def split_strings(*strings, separator=","): + ''' Given an array of strings and a character separator. + Return all words separated by the given character excluding empty strings + >>> split_strings("one.two.three","four.five","six", separator=".") + ['one', 'two', 'three', 'four', 'five', 'six'] + >>> split_strings("$perl$$", "$$raku$", separator="$") + ['perl', 'raku'] + ''' + return [word for string in strings for word in string.split(separator) if word != ""] + + +if __name__ == "__main__": + import doctest + + doctest.testmod() -- cgit