I want to fill in a string with a specific format in mind. When I have a single value, it's easy to build it:
>>> x = "there are {} {} on the table.".format('3', 'books')
>>> x
'there are 3 books on the table.'
but what if I have a long list of objects
items =[{'num':3, 'obj':'books'}, {'num':1, 'obj':'pen'},...]
and I want to construct the sentence in the exact same way:
There are 3 books and 1 pen and 2 cellphones and... on the table
How would I be able to do that, given that I don't know the length of the list? Using format
I could easily construct the string, but then I have to know the length of the list beforehand.