0

I want to keep inputting numbers without breaking the execution of program so my program can say if the number is even or odd for every input. It just does it once and it breaks. Please help!

I've been trying the while and continue but no luck so far.

print('Please enter a number so I can check if it is even or odd.')
number = int(input())
mod = number % 2

if mod > 0:
    print('This number is odd.')
else:
    print('This number is even.')

I expect to keep inputting numbers non-stop.

2 Answers 2

2
while True:
    print('Please enter a number so I can check if it is even or odd.')
    number = int(input())
    mod = number % 2

    if mod > 0:
        print('This number is odd.')
    else:
        print('This number is even.')

This will work in your case

Sign up to request clarification or add additional context in comments.

Comments

-1

You use def function

def m(number):
       if(number == "exit"):
                   return
        else:
              Num=number%2
              If( m>0):
                   print("odd")
               else:
                     print("even')
        return m(number)

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.