wrong answer in python

I am getting wrong answer in python 2.7 for the following code for the problem Life, the Universe, and Everything(the last problem among the EASY ones for practice). Cannot figure out why because i have used the same logic in java and it gave me correct answer.

def TEST():
  while True:
    x=int(raw_input())
    if x!=42:
      print x
    else:
      break

There are two things u can do to correct the code…

1st: call the test fxn…

def TEST():
  while True:
    x=int(raw_input())
    if x!=42:
      print x
    else:
      break
TEST()

2nd: dont define the test fxn…

while True:
    x=int(raw_input())
    if x!=42:
      print x
    else:
      break

hope this helps…:slight_smile:

the function “TEST” that you are creating is not called from anywhere. so it is not giving any output.here is the correct code http://ideone.com/9j36mO

thank you…that worked

glad could help…:slight_smile: