0

I have learned Python for about 4 months, I thought I know every basics now. But currently I accidently tried a simple python expression, and the result is out of my expectation.

for example:

test = [1,2,3,4]

test[0:-1:-1]

and the result is an empty list([]).

However, my expected result is [3,2,1] for "test[::-1]" will output "[4,3,2,1]".

Can anyone tell me why?

Anurag Dabas
  • 23,866
  • 9
  • 21
  • 41
JadeChest
  • 1
  • 1
  • 1

0 Answers0