DELHI'S ODD EVEN Python

I have written the following code:-

N=int(input())
a=[]
sumodd=0
sumeven=0
for x in range(0,N):
    a.append(input())
    b=a[x]
    if(int(b[x])%2==0):
        sumeven+=int(b[x])
    else:
        sumodd+=int(b[x])
    if((sumeven%4==0)or(sumodd%3==0)):
        print("Yes")
    else:
        print("No")

The code seems to be working fine in the IDLE, but shows the following error on HackerBlocks:-

Traceback (most recent call last):
  File "source", line 1, in <module>
    N=int(input())
ValueError: invalid literal for int() with base 10: 'undefined'

Kindly help me out, I am just a beginner.

N=int(input())
a=[]
sumodd=0
sumeven=0
for x in range(0,N):
a.append(input())
b=a[x]
if(b%2==0):
sumeven+=b
else:
sumodd+=b
if((sumeven%4==0)or(sumodd%3==0)):
print(“Yes”)
else:
print(“No”)

i don’t know what exactly the problem is but try the above code with proper indentation

Traceback (most recent call last):
  File "prog.py", line 1, in <module>
    N=int(input())
  File "<string>", line 1, in <module>
NameError: name 'undefined' is not defined

This error pops up

using Python 3 right ?

Thanks for giving time
I am sorry the compiler was set to python 2.7. But when python 3 was set the following error poped up:-

Traceback (most recent call last):
  File "source", line 1, in <module>
    N=int(input())
ValueError: invalid literal for int() with base 10: 'undefined'

it is working fine on my system i didn’t try on hackerblocks, maybe there is some issue with hackerblocks.
Don’t waste your energy on this if it is working fine on IDLE
and move forward with the course

Yes, It’s working on my IDLE
The thing is that I am unable to score points due to this\

Anyways, thanks so much for your help

In hackerblocks you should click provide custom input button to run the program else the STDIN remains empty ! If you’ll try to submit, it will accept.

But the test case failed, I contacted support and they says that my code didn’t do type conversion from string to int

Actually the support was me only :sweat_smile: and I confused it with a different problem. As far as failing test cases are concerned that means you are missing out on some edge cases!

try using
N= raw_input()
N=int(N)
Then give custom input in hacker blocks and run the program.

this is python2 way and raw_input is not available in python3

but hackerblock compiler had python 2.X compiler

Ohh, thanks jatin bhaiya, the code has worked without any errors, I will check for the test case.

Thank you sooo much::kissing_heart::kissing_heart:

The reason you had ValueError is because int cannot convert an empty string to the integer. In this case you’d need to either check the content of the string before conversion, or except an error:

try:
   int('')
except ValueError:
   pass      # or whatever