diff options
| author | Steven <steven1170@zoho.eu> | 2024-07-24 11:29:04 +0100 |
|---|---|---|
| committer | Steven <steven1170@zoho.eu> | 2024-07-24 11:29:04 +0100 |
| commit | 76161f95b561c1efaec380d74597429a28490460 (patch) | |
| tree | 9e8601de4bfe81a254fcd9fca80e4776ef0c1d73 /challenge-279/steven-wilson/python | |
| parent | e3042c4327200990cfc2d05943479f2aa713aa80 (diff) | |
| download | perlweeklychallenge-club-76161f95b561c1efaec380d74597429a28490460.tar.gz perlweeklychallenge-club-76161f95b561c1efaec380d74597429a28490460.tar.bz2 perlweeklychallenge-club-76161f95b561c1efaec380d74597429a28490460.zip | |
handle print w/ 0 vowels
Diffstat (limited to 'challenge-279/steven-wilson/python')
| -rw-r--r-- | challenge-279/steven-wilson/python/ch-2.py | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/challenge-279/steven-wilson/python/ch-2.py b/challenge-279/steven-wilson/python/ch-2.py index be2b25d38f..0b9478b238 100644 --- a/challenge-279/steven-wilson/python/ch-2.py +++ b/challenge-279/steven-wilson/python/ch-2.py @@ -22,8 +22,11 @@ def split_string(string, print_strings=False): return False if print_strings: - split_index = int(len(position_vowels)/2) - 1 - (start, stop) = (position_vowels[split_index], position_vowels[split_index+1]) + if len(position_vowels) < 2: + (start, stop) = (0, len(string)-1) + else: + split_index = int(len(position_vowels)/2) - 1 + (start, stop) = (position_vowels[split_index], position_vowels[split_index+1]) pprint([(string[:i+1], string[i+1:]) for i in range(start, stop)]) return True |
