I am trying to create a mail body template dynamically based on some conditions.
body = """ New product has created by {user}
This can be viewed by clicking here {link}
Logs is here {link2}
"""
I need to format this string based on some conditions, like:
if 'user' in params:
body.format(user='username')
if 'link' in params:
body.format(link='new link')
if 'link2' in params:
body.format(link2='new link2')
I know I can do like below,
body.format(user='username',link='new link',link2='new link2')
But i have to do this based on the above conditions. Is there any way to achieve this in python.?
I have found this and this didn't help me.
Thanks in advance.