SyntaxFix
Write A Post
Hire A Developer
Questions
This can be done with string formatting. It works with the % notation as well as .format() and f-strings (new to 3.6)
print '%s' % (a if b else "")
or
print '{}'.format(a if b else "")
print(f'{a if b else ""}')