I have written code to solve a problem.
Here is My Code:
t=int(input())
print("")
while(t):
s=0
n=int(input())
for i in range(n):
no=int(input())
s=s+no
if s%n==0:
print("YES")
else:
print("NO")
print("")
t-=1
When I run it on the OS X terminal, it works fine. But when I run it on IDEone
or Submit it as a solution, it gives an error on line 5
:
ValueError: invalid literal for int() with base 10: ''
I am unsure of what the problem is.
You are not handling if the user enters nothing, in other words empty string
>>> int('')
Traceback (most recent call last):
File "<pyshell#3>", line 1, in <module>
int('')
ValueError: invalid literal for int() with base 10: ''
You can use a variety of techniques to more robustly accept input from the user.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.