I'm pulling a set of image urls and their respective titles. I've tried creating a hash or associative array, but the data seems to overwrite so I only end up with the last item in the array.
For example;
thumbnail_list = []
for file in media:
thumbnail_list['url'] = file.url
thumbnail_list['title'] = file.title
I've even tried creating two lists and putting them in a larger one.
thumbnail_list.append('foo')
thumbnail_urls.append('bar')
all_thumbs = [thumbnail_list], [thumbnail_urls]
I'm trying to create a link out of this data:
<a href="image-url">image title</a>
I keep getting close, but I end up looping over too much data or all of the data at once in my django template.
Ideas?
Edit: Maybe zip() is what I need?
questions = ['name', 'quest', 'favorite color']
answers = ['lancelot', 'the holy grail', 'blue']
for q, a in zip(questions, answers):
print 'What is your {0}? It is {1}.'.format(q, a)