html - Python: Print list of unknown length? -


i'm trying use python print html file.

is there way incorporate following print statement? perhaps using format method?

current situation:

foo = ['some_image1.com', 'some_image2.com']  print '''<img src="' + foo[0] + '"> <img src="' + foo[1] + '"> <img src="' + foo[2] + '">''' # desired behavior ignore foo[2] 

how can past this? should not use list?

thank you!

print ''.join(map('<img src="{}">'.format, foo)) 

or

print '<img src="%s">' * len(foo) % tuple(foo) 

(if foo tuple, wouldn't need tuple(...)).

i wouldn't latter, though, except when code golfing (where did use this).


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -