How to get [2,4,7] from the my_list [1,2,3,4,5,6,7,8,9], which is the list of elements at the equal interval(in this case, 3) "from the end" of the my_list?
my_list =[1,2,3,4,5,6,7,8,9]
# how to get [2,4,7] from the list above?
CodePudding user response:
if [1,4,7]
is supposed to be the result this snipped of code should do the job
my_list=[1,2,3,4,5,6,7,8,9]
print(list(reversed(my_list[-3::-3])))
result
[1, 4, 7]