Slice with Negative Positions in Python

In slices, you can also access elements by negative indices. In this case, they will be counted from the end of the sequence. Let's make a slice from the third to the penultimate element:

pythontxt = '123456789'
res = txt[2:-1]

print(res) # '345678'
Задание 1

Given a string:

pythontxt = '123456789'

Get the following slice from it:

python'567'
Задание 2

Given a list:

pythonlst = ['a', 'b', 'c', 'd', 'e', 'f']

Get the following slice from it:

python['b', 'c', 'd']
Задание 3

Given a list:

pythonlst = ['a', 'b', 'c', 'd', 'e', 'f']

Get the following slice from it:

python['f']