In this task I can only write the function and the rest of the code is given, so the original list l in the function should be changed without creating a new one. However, as I understood it when I already read through similar questions, this is not a good idea at all.
My try looked like this:
import random
def removeNegatives(listOfIntegers):
for i in listOfIntegers:
if i < 0:
listOfIntegers.remove(i)
#code can not be changed from here on!
l = []
for i in range(0, random.randint(15,25)):
l.append(random.randint(-15,15))
print ("Before:", l)
removeNegatives(l)
print ("After:", l)