The code does not require explanation.
def getNegativesList(postivesAndNegativeslist):
if postivesAndNegativeslist is None:
return None
elif len(postivesAndNegativeslist) == 0:
return None
negativesList = []
for val in postivesAndNegativeslist:
if val<0:
negativesList.append(val)
return negativesList
print(getNegativesList([2,-3,-5,10,-1]))
6
solved My code isn’t executing [closed]