Take an array and remove every second element from the array. Always keep the first element and start removing with the next element.
My code:
def remove_every_other(my_list):
new_list = []
divisor = 2
counter = 2
for element in my_list:
if counter % divisor == 0:
new_list.append(element)
counter += 1
return new_list
def remove_every_other(my_list):
return my_list[::2]