0

So I'm new to python and was doing this python prog for an online coding site.the problem is when i run my code in IDLE it compiles perfectly and gives the correct output but when i run it in the online compiler it gives me a 'Runtime Error -NZEC' and output

Traceback (most recent call last):
  File "/tmp/editor_trsource_1407389496_406898.py", line 5, in 
    A=int(input())
  File "", line 1
    3 5 2
  ^
SyntaxError: invalid syntax

Its really annoying as i cannot see the problem. Any help is gratefully accepted

array1=[]
array2=[]
T=int(input())
for z in range(T):
    A=int(input())
    B=int(input())
    N=int(input())
    for i in range(0,10**7):    
        try:
            array1.append(i+1 * int(A))
        except MemoryError :
            break

    for j in range(0,10**7):
        try:
            array2.append(j+1 * int(A))
        except MemoryError :
            break
    filter(None ,array1)
    filter(None ,array2)
    array3 = array1 + array2
    array3 = sorted(set(array3))
    print (array3[N])
Ricky
  • 284
  • 1
  • 3
  • 19
Clinton Dsouza
  • 330
  • 4
  • 20

1 Answers1

1

input() is equal to eval(raw_input(prompt)). The error you saw was Python tried to eval("3 5 2") and failed. Followed code can let you input "3 5 2" and assign to A B C

>>> (A, B, C)=([int(x) for x in raw_input('3 numbers pls:').split()])
3 numbers pls:3 5 2
>>> A,B,C
(3, 5, 2)

btw, if you don't need eval but only want to get the original content, you can use raw_input()

dumduke
  • 471
  • 4
  • 15
  • i ran your code in IDLE and it ran without issues but when i ran it in the online complier at HACKEREARTH it shows me this `Traceback (most recent call last):` `File "/tmp/editor_trsource_1407390909_749862.py", line 5, in (A, B, N)=([int(x) for x in input().split()])` `File "", line 1` `3 5 2` ^ `SyntaxError: invalid syntax` – Clinton Dsouza Aug 07 '14 at 05:57
  • @ClintonDsouza, check this page on [HackerEarth](http://code.hackerearth.com/ae8a4dG?key=8014e8d270654bf38953b6a6ee968f36). It's a editable URL. The first print it just to put the result in a new line. – dumduke Aug 07 '14 at 06:05