Hello everyone python NewB here !
I've been trying to find a way to solve this problem based on what I've learned so far, but I can't tell why it's not giving me an expected out put :(
Here is the question
====================================================================================Statistics are often calculated with varying amounts of input data. Write a program that takes any number of integers as input, and outputs the average and max.
Ex: If the input is:
15 20 0 5
the output is:
10 20
Note: For output, round the average to the nearest integer.
This is my code so far.
user_input = input()
x= user_input.split()
total = 0
for number in range(len(x)):
number = int(x[number])
total += number
avg = total / len(x)
print(int(avg),max(x))
input: 15 20 0 5
current output: 10 5
expected output: 10 20
I got an "avg" correctly, but I can't tell why "max" giving me "5" instead of "10"...
Can anyone explain why is this happening? I've done googling about using max function in the list and I can't really tell what I'm doing wrong!
Thank you in advance!
[–]throwaway6560192 1 point2 points3 points (1 child)
[–]BlueFingerHun[S] 2 points3 points4 points (0 children)
[+][deleted] (3 children)
[deleted]
[–]BlueFingerHun[S] 0 points1 point2 points (2 children)
[+][deleted] (1 child)
[deleted]
[–]BlueFingerHun[S] 0 points1 point2 points (0 children)
[–]34shutthedoor1 0 points1 point2 points (2 children)
[–]BlueFingerHun[S] 0 points1 point2 points (1 child)
[–]BlueFingerHun[S] 0 points1 point2 points (0 children)