aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMohammad Sajid Anwar <Mohammad.Anwar@yahoo.com>2024-07-24 11:31:13 +0100
committerGitHub <noreply@github.com>2024-07-24 11:31:13 +0100
commita990df737d3dc4908227daa14507d9ff97716ed9 (patch)
tree2dc820f283428c2b10afc528b9e9aea2fe2afca9
parent9b74ec607f269641387884e9d0f72b5c378cef9b (diff)
parent76161f95b561c1efaec380d74597429a28490460 (diff)
downloadperlweeklychallenge-club-a990df737d3dc4908227daa14507d9ff97716ed9.tar.gz
perlweeklychallenge-club-a990df737d3dc4908227daa14507d9ff97716ed9.tar.bz2
perlweeklychallenge-club-a990df737d3dc4908227daa14507d9ff97716ed9.zip
Merge pull request #10488 from oWnOIzRi/week279
handle print w/ 0 vowels
-rw-r--r--challenge-279/steven-wilson/python/ch-2.py7
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