Answer the question
In order to leave comments, you need to log in
What is the best way to return?
Is there any difference in these 2 options? If yes, which one is better? Specifically, is it possible to do as in the second option for each if return or is it better to do one, as in the first example?
def test(a):
if a == "abc":
result = True
elif a == "123":
result = False
return result
def test(a):
if a == "abc":
return True
elif a == "123":
return False
Answer the question
In order to leave comments, you need to log in
In the specific example, nothing else is needed
def test(a):
return a == "abc"
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question