Issue
I would like to take create a code that takes an input of numbers, and then takes the average (mean) of these numbers. So far, I have this:
from statistics import mean
numbers=int(input("Enter some numbers. Seperate each number by a space: ")
average=mean(grades)
print(average)
Running this code gives me an error stating "invalid literal for int() with base 10: ' 12 13 14 15 16 17 17'". I have tried to convert the input into a list, but this also failed; I don't know what else to do or try.
Solution
numbers=[int(x) for x in input("Enter some numbers. Seperate each
number by a space: ").split()]
print(numbers)
average=mean(numbers)
print(average)
Answered By - Andres Ospina
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.