I have difficulties to generate a dictionary that contains identical keys. The actual code:
source = []
key = []
for foto in fotos.split(','):
source.append(str(foto))
key.append("source")
dictA = dict(zip(key, source))
pprint(dictA)
The output:
{'source': 'https://www.example.com/fma600/9364f794ed4e5cfc3ba9416ef4ebe065.jpg'}
But I need this dict output:
"pictures":[
{"source":"http://yourServer/path/to/your/picture.jpg"},
{"source":"http://yourServer/path/to/your/otherPicture.gif"},
{"source":"http://yourServer/path/to/your/anotherPicture.png"}
]
The problem is: the API needs to duplicate pictures using the same key "source"
. When I use dict
, its not possible to duplicate and create another key with the same name.