0

How to fix this error in this code

Calculate the arithmetic mean of integer numbers you will receive the integers on separate lines .the numeric sequence ends with a period . , so stop readind the input on it https://code.sololearn.com/cNiIxJn6s7DU/?ref=app

21st May 2020, 11:16 PM
Taher Mohamed Ismail
Taher Mohamed Ismail - avatar
4 Respostas
+ 3
total = 0 i = 0 while True : n = input() if n == '.': break total += int(n) i +=1 print(total / i)
22nd May 2020, 12:31 AM
Abhay
Abhay - avatar
+ 1
Hi, I made some Small changes, check it out. I hope it gets closet to what you are looking to do. https://code.sololearn.com/cre5WJKH4E1Z/?ref=app
22nd May 2020, 1:56 AM
Josshual A. Toro M.
Josshual A. Toro M. - avatar
0
Try this: total = 0 i = 0 while True : n = input() total += int(n) if n.isnumeric() else 0 if n == '.': break i +=1 print(total/i)
21st May 2020, 11:37 PM
4lx
4lx - avatar
0
Thank you so much it still wrong what about if we enter -3,6,-6,-5,3,1,-1,0,. we will get 1.25 which is wrong answer any ideas .i apprecited your efforts
21st May 2020, 11:43 PM
Taher Mohamed Ismail
Taher Mohamed Ismail - avatar