# Why is my while loop being ignored?

The prompt is: A fisherman needs a program that tallies the number of small,medium, and big fish caught. A fish is considered small if it weighs less than 1 lbs, medium if it weighs between 1 and 2 lbs, and big if it weighs more than 2 lbs. Write a function that 1) accepts the fish weight as a keyboard input 2) tallies the number of fish in each category 3) prints the final number of fish in each category as well as the total number of fish caught. Steps 1 and 2 should be repeated as long as the weight entered is positive, a negative weight would terminate the data entry and trigger step 3

When I proceed to run my code, the print statements all return 0.

fishweight = float(input(“Enter weight of fish in pounds:”))
def fishtally(fishweight):
nsmall = 0
nmedium = 0
nbig = 0
print (“Number of small fish=”, nsmall)
print (“Number of medium fish=”, nmedium)
print (“Number of big fish=”, nbig)
fishtotal = nsmall + nmedium + nbig
print (“The total number of fish caught=”, fishtotal)
while fishweight >0:
if fishweight <1 and fishweight >0:
nsmall += 1
return nsmall
elif fishweight >=1 and fishweight <=2:
nmedium += 1
return nmedium
else:
nbig += 1
return nbig
fishtally(fishweight)

The while loop is not being ignored.

Since `nsmall`, `nmedium`, and `nbig` are all defined/declared in the function,
they are set to 0 (in the first 3 lines of the function) every time the function runs.
(These variables have function scope.)

Also, why do you have a while loop in the function?
you could accomplish “adding in a single fish” with just an if-statement instead of that `while`.

Note that printed the amount of fish before you added in the new fish in the function. Do you want the new amount of fish printed instead?