Answers for "how to put a condition for a string to display or not"

0

how to put a condition for a string to display or not

>>> gender= "male"
>>> print "At least, that's what %s told me." %("he" if gender == "male" else "she")
At least, that's what he told me.
Posted by: Guest on February-12-2021
0

how to put a condition for a string to display or not

>>> s = "At least, that's what {pronoun} told me.".format(pronoun="he" if gender == "male" else "she")
>>> s
"At least, that's what he told me."
Posted by: Guest on February-12-2021

Code answers related to "how to put a condition for a string to display or not"

Browse Popular Code Answers by Language