Please help to solve this. I will be very thankful!
t = int(input())
count = 0
m = []
for i in range(0,t):
num = int(input())
m.append(num)
for z in m:
for i in range(0,z):
if z%i==0:
count = count 1
else:
count = count 0
if count % 2 == 1:
print('YES')
else:
print('NO')
count = None
Traceback (most recent call last): File "solution.py", line 9, in if z%i==0: ZeroDivisionError: integer division or modulo by zero
CodePudding user response:
You can use 1 as starting value to avoid this error(Zero division)
for i in range(1,z):
CodePudding user response:
The variable i is defined in range(0,z), it always starts from zero. Mathematically the module of zero is undefined, that's why you're getting the error.