I'm working on a program that accumulates 5 ratings and makes an average value

75 views Asked by At

So this program must use 2 functions, and calculate the average in the main function and then pass it to the 2nd function. I'm running an issue where when calculating the average all it does is divide the last number by 5 instead of the sum of all the 5 numbers. I have to use a loop to ask for the input and have validation. I'm really not sure what's happening here to make it not work right. I'm very new to python and I could use some help. Thank you

def main():
    ASK_COUNT = 5
    total = 0
    for score in range(ASK_COUNT):
        rating = float(input('Please enter the critics score between 0 and 10: '))
        total = total + rating
        while rating <= 0 or rating > 10.0:
            print('ERROR: Please enter a score between 0 and 10')
            rating = float(input('Enter a correct score: '))
    average_rating = rating / 5
    print(average_rating)
    determine_stars(average_rating)


def determine_stars(average):
    if average  >= 9.0 and average <=10.0:
        print('9.0 - 10.0:        *****')
    elif average >= 8.0 and average <=8.9:
        print('8.0 - 8.9:         ****')
    elif average >= 7.0 and average <=7.9:
        print('7.0 – 7.9:         ***')
    elif average >= 6.0 and average <=6.9:
        print('6.0 – 6.9:         **')
    elif average >= 5.0 and average <=5.9:
        print('5.0 – 5.9:         *')
    else:
        print('Below 5.0          No stars')

main()
0

There are 0 answers