From 4717ccf84e374fe2d17a04c06425857f9ea5a35e Mon Sep 17 00:00:00 2001 From: Ethan Dalool Date: Thu, 30 Jan 2020 12:34:03 -0800 Subject: [PATCH] Fix excise to have no effect if s doesn't contain split marks. --- brename.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/brename.py b/brename.py index f889999..bce9cba 100644 --- a/brename.py +++ b/brename.py @@ -67,7 +67,9 @@ def excise(s, mark_left, mark_right): excise('What a wonderful day [soundtrack].mp3', ' [', ']') -> returns 'What a wonderful day.mp3' ''' - return s.split(mark_left)[0] + s.split(mark_right)[-1] + if mark_left in s and mark_right in s: + return s.split(mark_left)[0] + s.split(mark_right)[-1] + return s def longest_length(li): longest = 0