I am trying to format a string where the same variable sometimes needs to be appended with new line and tab and other times not.
I don't see any other options but using two different variables, do you think this could be achieved using the same variable?
Example String The actual string is long, and I have may variables which sometimes requires no formatting and sometimes require to appned either new line and tab.
test_str="""
list {values}
list
{values}
"""
for above I want to achieve following output.
list 1,2,3
list
1,
2,
3
the current approach, which is not working.
values = ",".join(["1","2","3"])
print test_str.format(values=values)
if I change the values to values1 and values2 then I can apply different formatting.
values1 = ",".join(["1","2","3"])
values2 = ",\n\t".join(["1","2","3"])
print test_str.format(values1=values1, values2=values2)