Python Forum

Full Version: numbers in list - max value and average
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Program ask user for input (how many fish he caught per day - 10 days) and than it needs to output average per day and output number from list that is higher than average

list = []
above_average = 0
i = 1
while i < 11:
    fish = int(input("Catched fish today: "))
    list.append(fish)
    i+=1
    average = sum(list) / len(list)
    if fish > average:
        above_average += 1
print ("Average per day: " + str(average))
print ("Catch above average " + str(above_average))
This is what i've done and it works but at catch above average i need to print which number from list is higher than average not how many...
Fisherman Alex needs to enter amount of fish he catched every day for 10 days.

Program needs to return average for every day and number of day he catched more fish than average

list = []
above_average = 0
i = 1
while i < 11:
    fish = int(input("Catched fish today: "))
    list.append(fish)
    i+=1
    average = sum(list) / len(list)
    if fish > average:
        above_average += 1
print ("Average per day: " + str(average))
print ("Catch above average " + str(above_average))


This is what i've done and it works but at catch above average i need to print which number from list is higher than above not how many...
you need to store the user input in a list. Then, after all numbers are in the list - iterate over list and find [count of] numbers that are higher than average