insert multiple elements in string in python
- by Anurag Sharma
I have to build a string like this
{ name: "john", url: "www.dkd.com", email: "[email protected]" }
where john, www.dkd.com and [email protected] are to be supplied by variables
I tried to do the following
s1 = "{'name:' {0},'url:' {1},'emailid:' {2}}"
s1.format("john","www.dkd.com","[email protected]")
I am getting the following error
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
KeyError: "'name"
Dont able to understand what I am doing wrong