thanks for helping me. I'm learning Python and I cannot make it work to have a response with all the info in a single dictionary by running two for loops.
See this example, if I run the loop like this...
mylist1 = ["image1", "image2", "image3"]
pictures_list = ["image1_url", "image2_url", "image3_url"]
mydict = {}
for item in mylist1:
mydict['name'] = item
for url in pictures_list:
mydict['url'] = url
print(mydict)
I have this answer, which iterates 3 times
{'name': 'image1', 'url': 'image1_url'}
{'name': 'image1', 'url': 'image2_url'}
{'name': 'image1', 'url': 'image3_url'}
{'name': 'image2', 'url': 'image1_url'}
{'name': 'image2', 'url': 'image2_url'}
{'name': 'image2', 'url': 'image3_url'}
{'name': 'image3', 'url': 'image1_url'}
{'name': 'image3', 'url': 'image2_url'}
{'name': 'image3', 'url': 'image3_url'}
If I remove one indentation to the print statement like this...
mylist1 = ["image1", "image2", "image3"]
pictures_list = ["image1_url", "image2_url", "image3_url"]
mydict = {}
for item in mylist1:
mydict['name'] = item
for url in pictures_list:
mydict['url'] = url
print(mydict)
I got one a single iteration to add the key but it doesn't iterate on the value assignment.
{'name': 'image1', 'url': 'image3_url'}
{'name': 'image2', 'url': 'image3_url'}
{'name': 'image3', 'url': 'image3_url'}
So I wonder how I could actually build the code to get an output like this
{'name': 'image1', 'url': 'image1_url'}
{'name': 'image2', 'url': 'image2_url'}
{'name': 'image3', 'url': 'image3_url'}