I have been set a small task for my CS class in which I have to write a method in Python to delete the items at prime index locations within a list, up to index 50.
I have attempted to produce the method, as shown below, however when i attempt to print the list at the end of the method, it should return the list with the values in prime index locations deleted, however it is simply just returning the full list (numbers 1 to 50).
My function:
def listDelete(list):
for i in list:
if i %2 != 0 & i % 3 != 0:
del list[i]
return list
And I call the function by using:
listDelete(range(1,50))
I am very new to python so apologies if this is a very simple fix, or glaring error,but any help would be much appreciated!