Home > OS >  Why is my python function isn't printing even or odd?
Why is my python function isn't printing even or odd?

Time:02-11

'''def even_or_no(number): if number % 2 != 0: return 'odd' else: return 'even'

even_or_no(34)'''

Hello, I am trying to print even given that the argument is 34, but it doesn't do that. When I use print statement it works fine. I don't know why my program doesn't return even or odd and prints it onto the screen.

CodePudding user response:

return simply sends the result of calling your even_or_no function back to wherever the function was called. It does not print the result unless you explicitly tell it to, such as by calling print(even_or_no(34)).

You can read more about return statements in Python here.

  • Related