There are 3 links to the image (imgs list) and 3 id attached to them (also a list, offer_ids). Sorting does not need anything, they are ordered relative to each other. But how to output them in a loop? I am new to python.

img = self.get_argument("img", None) if len(img) > 0: imgs = img.split(',') offer_id = self.get_argument("offer_id", None) if len(offer_id) > 0: offer_ids = offer_id.split(',') 

How to unite them so that it would be something like:

 for img, offer_id in imgs, offer_id: 

And then we go through the first elements in the lists, the second, the third ...

  • Completed the question. - Timur Musharapov

1 answer 1

Can so

 for index, url in enumerate(imgs): print('<img src="{}" id="{}">'.format(url, offer_ids[index])) 

Or so

 for url, img_id in zip(imgs, offet_ids): print('<img src="{}" id="{}">'.format(url, img_id)) 
  • My answer will suit you. - Sergey Gornostaev
  • The second is perfect, thank you very much! - Timur Musharapov