2. is even


#1

I have written down the following code and it gives the correct answer.

def is_even(x):
if x%2==0:
return True
else:
return False

the instructions say that I should use return instead of print. When I write my code with print it also gives the correct answer.

So I am wondering what is the difference between return and print?

Thx


#2

It could be your browser send cached data when you swap return for print, and that is why it approves. Well, print will print something to the console, return means the function ends and hands you something back:

def example():
   return "hello world"
store = example()
print store

#3

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.