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)