Please, could any help with this code, Im trying get the ideia how this works test = [0, 1, 4, 9, 16, 25, 36, 49, 64, 81] print(test[7:5:-1])
8/9/2016 6:56:24 PM
Antônio Alexandre Neto2 Answers
New Answerthe index (between the [ ]) had three parts: first number stands for the startindex, here it is 7, which corresponds to test[7]=49. second number stands for end index, it is test[5]=25. third number is the stepsize of the range: -1 means reversed. So test[7:5:-1] = [49,36]. remark: Python works with zero based indexing. remark: the end index is never included.
Sololearn Inc.
535 Mission Street, Suite 1591Send us a message