I have the following string for example:
a-b-c-d-e-f
I want to remove the first element and the last two elements so the output will be:
b-c-d
I tried to use rsplit
, But the output is list:
print string.rsplit('-',)[1:-2]
['b', 'c', 'd']
How can i combine the list element back to be a string? Is there any easier way to remove the elements instead of using rsplit
?