2 / 2
Jun 2015

problem : TEST - Life, the Universe, and Everything
language: python 3 (3.4)
output: runtime error (NZEC)

Problem details :
Your program is to use the brute-force approach in order to find the Answer to Life, the Universe, and Everything. More precisely... rewrite small numbers from input to output. Stop processing input after reading in the number 42. All numbers at input are integers of one or two digits.

Example

Input:
1
2
88
42
99

Output:
1
2
88

My solution:

def take_input():
    n = (input("Enter new number"))
    if( n != 42 ):
        print(n)
        take_input()
def main():
    Print
    number = take_input()
    return 0
if __name__ == "__main__":
    main()

Someone please explain me why this is getting an error I run this same code my machine everything works.
This is my frist time and first ever problem on spoj. And I am aware that I might be missing something obvious but I tried everything I could think of.
Thanks for help.

  • created

    Jun '15
  • last reply

    Jun '15
  • 1

    reply

  • 1.1k

    views

  • 2

    users

n = (input("Enter new number"))

With this you output the unnecessary "Enter new number", this text isn't awaited and gives you WA.
Try instead

n = (input())