<div dir="ltr">On Fri, Dec 5, 2014 at 10:31 AM, <<a href="mailto:gaurangnshah@gmail.com">gaurangnshah@gmail.com</a>> wrote:<br>><br>> Hi Guys,<br>><br>> I am trying to combine string and dict in the print statement, however getting an error. Would someone let me know what will be correct way to do that.<br>><br>> stats={'lname': 'shah', 'fname': 'gaurang'}<br>> a=test<br>><br>> print "%s %(fname)s %(lname)s" %(a,stats)<br>><br>> Following is the error I am getting<br>> Traceback (most recent call last):<br>>   File "<stdin>", line 1, in <module><br>> TypeError: format requires a mapping<div><br></div><div>You need to use either a tuple or a mapping, not a mapping inside a tuple. Or switch to using str.format, which allows more advanced attribute/item look-ups like this.</div></div>