This is what I am trying to do:
- Get some arguments
- Based on the arguments, create a string
- Returns a string
However, for this I could see 3 possible ways:
def form_statement(subject, verb, object):
greetings = ""
if subject in ("Paul", "Raj"):
greetings = "mister"
return "%s %s %s %s" % (subject, verb, object, greetings)
The second way to do this:
def form_statement(subject, verb, object):
if subject in ("Paul", "Raj"):
greetings = "mister"
else:
greetings = ""
return "%s %s %s %s" % (subject, verb, object, greetings)
And the third way:
def form_statement(subject, verb, object):
greetings = "mister" if subject in ("Paul", "Raj") else ""
return "%s %s %s %s" % (subject, verb, object, greetings)
Is there any other better way to do something like this? Right now I am choosing the first method, since the โprocessingโ for receiving the welcome line is the function itself and makes the line more than 80 characters when the third method is used.
EDIT: , - , , ( ). , , , , . , , , .