In this chapter we will look at another question from CodeWars, this question goes like this: Given a list of items, create a method which will keep on removing the next item in the list and returning a list without the next item.
The keyword here is to remove every next item in a list.
def remove_every_other(my_list):
keep = []
for i in range(len(my_list)):
if(i % 2 == 0):
keep.append(my_list[i])
return keep
A very simple solution for a simple 8 Kyu question on CodeWars.
from Planet Python
via read more
No comments:
Post a Comment