0

I am trying to put a value in using input function so that function can print even or odd without using return.

def even_odd (n):
    if n % 2 == 0 :
        print ("even")
    else:
        print ("odd")
    
input (even_odd(int(write number)))
1
  • Other way around -- the input() should go where you have write number. Commented Oct 31, 2020 at 3:10

2 Answers 2

1

You just mixed it up you would want something like this

def even_odd (n):
if n % 2 == 0 :
    print ("even")
else:
    print ("odd")

even_odd(int(input("write number")))

You also need to have the text that the user would see in the console to be a string, so make sure not to forget those quotations!

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

Comments

0

Take a look at the documentation for input(). It tells you that it takes a prompt, which is printed, and then reads the input. You can more-or-less copy the example they give:

s = input('--> ')  

If you want the prompt to be something other than --> you can, of course, change that to any string. Then it's just a matter of turning the string to integer. It looks like you understand that.

def even_odd (n):
    if n % 2 == 0 :
        print ("even")
    else:
        print ("odd")

s = input('--> ')   # s it the value you put in the input

even_odd(int(s))
# --> 5
# odd

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.