I have a function to check for the "negative", "positive" and "zero" value in the list. Below is my function:
def posnegzero(nulist):
for x in nulist:
if x > 0:
return "positive"
elif x < 0:
return "negative"
else:
return "zero"
But when I run this function, it stops after checking the value of the first number in the list. For example:
>>> posnegzero([-20, 1, 2, -3, -5, 0, 100, -123])
"negative"
I want it to continue for the entire list. In the above function, if I change every instance of return
to print
, then it does what it should but now I don't want it to say None
when the function is complete. Any ideas of where I went wrong?