Hello friends,
I am learning Python and have one doubt if someone could help. If this is not appropriate question for this GG, could someone suggest where I may ask such questions (Google/AI did not help)
Using list slicing feature, is it possible to reverse a sub-portion of the list? e.g. array = [1, 2, 3, 4, 5]
print(array[::-1]) --> 5, 4, 3, 2, 1
likewise, I used print(array[-4:-1]) to get sub-array 2, 3, 4
if I wanted 4, 3, 2 instead, is there a way to achieve it using slicing,
if not, other than the traditional for loop, does Python have another way of doing it? I have learned list comprehension but not sure if it can help in such scenarios.
Thanks.