I've been working on a problem, and I'm not sure style/function wise which is generally considered best practice.
I have a function that serves multiple checks on the same string, and returns a value based on that string. Is it better style or function to use stacked if-statements or if-elif-else statements?
Example:
def f(s):
if s == 'Hey':
return 'Sup.'
if s == "How's it going?"
return 'Not bad.'
return 'I have no idea what you said.'
or
def f(s):
if s == 'Hey':
return 'Sup.'
elif s == "How's it going?"
return 'Not bad.'
else
return 'I have no idea what you said.'