Reputation: 1023
I'm working through a lesson and I'm stuck. Since I'm new with Python, it's hard to figure out where I'm going wrong.
#Write your two "if" statements below!
def true_function():
if #Fill in your `if` statement here!
return #Make sure this function returns `True`
def false_function():
if #Fill in your `if` statement here!
return #Make sure this function returns `False`
This is my proposed solution, which gives me an error;
#Write your two "if" statements below!
def true_function():
if 2 + 2 == 4: #Fill in your `if` statement here!
return 'True' #Make sure this function returns `True`
def false_function():
if 2 + 2 == 5: #Fill in your `if` statement here!
return 'False' #Make sure this function returns `False`
Can someone help me understand where I'm going wrong?
Upvotes: 0
Views: 141
Reputation: 48536
True
and False
are objects (or variables, or constants, or soft-keywords, or whatever you want to call them). They aren't strings.
return True
Your second function is also using a false condition, so the contents of the if
block will never run. It'll drop off the end and return None
instead.
Upvotes: 5