How to calculate average and range after input into list?

I need some help regarding calculating averages and ranges. I am using built-in functions such as sum(), len(), etc. and cannot seem to calculate the average or range. I am using it to write a small piece of code for fun but cannot seem to get it to work. any help is much appreciated. Thank you!

x = 1
number_list = []

while x == 1:
     input_number = input("PLease input an integer")
     if str.isdigit(input_number) == True:
         number_list.append(input_number)
     else:
         print("Please input a valid integer only.")
     continueornot = input("Would you like to continue adding data? PLease input 'Yes' to continue, and anything else to quit.")
     if continueornot == 'Yes':
        x = 1
     else:
           
            print("Here is the maximum number:", max(number_list))
            print("Here is the minimum number:", min(number_list))
            print("Here is the count:", len(number_list))
            print("Here is the average:" + sum(number_list) / len(number_list))
            print("Here is the range:", range(number_list))
            quit()


Read more here: https://stackoverflow.com/questions/68462479/how-to-calculate-average-and-range-after-input-into-list

Content Attribution

This content was originally published by anonymous at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: