Created
December 22, 2020 14:06
-
-
Save costastf/8c3cd54877948edbaeafea7424335c09 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def split_element(input, index, splitting_character=' '): | |
# we don't accept to split on more than one character and check for length of list | |
if any([index > len(input), len(splitting_character) > 1]): | |
return input | |
# if splitting character is no character we default to a space | |
items = input[index].split(splitting_character or ' ') | |
# if we actually have items are remove the inital from the list and insert our elements | |
if len(items) > 1: | |
input.pop(index) | |
for count_, item in enumerate(items): | |
input.insert(index + count_, item) | |
return input |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment