I've been searching stackoverflow for a few hours now without finding a solution to my problem. I have a function where I want the output to be a dictionary, but I can only get it to print the first key + value. The "yield" statement won't work for some reason, so I'm wondering if there is another way to do it.
This is my code:
def myfunc(somedict):
x = list(somedict.values())
for i in x:
data = dict_from_otherfunc(i)
mylist = [float(max(data.values()))]
mydict = dict(zip([i], mylist))
return mydict
This returns a dictionary that looks like this:
{'abc': 1}
When I put print instead of return I get the desired output. How can i make this code return a dictionary with all values instead of only one?
Edit: Tried returning outside of for-loop, this returns only the last value of my dictionary.