O
O
Onigire2021-06-04 20:32:19
Django
Onigire, 2021-06-04 20:32:19

Why is the last element of the list not displayed?

How does it even work?
How can I include the last element of the list when slicing?

a = "123456789"
print(a[-1]) # Выводит 9
print(a[-3:-1]) # Выводит 78

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2021-06-04
@Onigire

How does it even work?

Open the documentation and read.
How can I include the last element of the list when slicing?

Remove -1it, just -3:.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question