1

I am trying to print this string

str = "container.insert({{ {0} ,{{ {{ {1}, {{ {2} ,{3} ,{4} , {5} }} }} }} }});"
str.format(prim_ident,country_ident,final[0],final[1],final[2],final[3])
fileWrite.write(str)

However the output of above that I get is

container.insert({{ {0} ,{{ {{ {1}, {{ {2} ,{3} ,{4} , {5} }} }} }} }});

Two problems the first problem is that i am getting double curly braces. I only want to show a single curly brace. But i read that you have to use double curly braces when u would like the curly brace to be present in the string the other problem is my format is not working (i.e) {0},{1} etc are not being replaced by their equivalent values. Can anyone please tell me what I am doing wrong ?

1 Answer 1

1

str.format() does modify the string in-place, you still need to save it to a variable, try adding str = :

str = str.format(prim_ident,country_ident,final[0],final[1],final[2],final[3])
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.