# Could someone describe what happened in alternative solution to the task?

``````values1 = [80, 109, 111, 109, 94, 93, 108, 107, 81, 111, 101, 114, 102, 81, 107, 120, 108, 92, 113, 119, 97]
values2 = [97, 119, 113, 92, 108, 120, 107, 81, 102, 114, 110, 111, 81, 107, 108, 93, 94, 109, 111, 109, 80]
is_reversed = True
for i in range(len(values1)):
if values1[i] != values2[-i - 1]:
is_reversed = False

# Alternative solution:
is_reverse = True
for i in range(len(values1)):
if values1[i] != values2[len(values1) - i - 1]:
is_reverse = False
``````

I donâ€™t understand this alternative solution. How does it works ? what would this code do behind the curtain?

to be more specific: I donâ€™t understand this part:

``````values2[len(values1) - i - 1]
``````
1 Like

Hi please provide a screen link as per these guidelines so that we can better assist you.

1 Like

Hello @drill_n_bass, to understand this letâ€™s see this example with a list with fewer values.

``````values1 = [1, 2, 3, 4]
values2 = [4, 3, 2, 1]
``````

Both lists have the same length, and also `values1` is `values2` reversed.
in `values1` letâ€™s start with the index in the first value, it is index `0`, the responding index in `values2` will be index `3` to get this 3 we did `4 - 0 - 1` that gives `3`, and thas why they used `values2[len(values1) - i - 1]`

Letâ€™s Understand the item in index `2` in `values1`, the corresponding item in `values2` is in index `1`, to get that `1` we did `4 - 2 - 1`.

I hope youâ€™ve understood now.

thank you
â€¦
I think I found another way/solution

``````for i in range(len(values1)):
if values1[i] == values2[-i : -1]:
is_reversed = True
print('is_reversed =', is_reversed)
``````

just wonder: is it works in a such way that I should put above:

``````is_reversed = False
``````

It would be - also - opposite to solutions listed above

1 Like