I would like to iterate through the key:value pairs in a dictionary and pass them as arguments in a function. In the function I am trying to return the value I am getting from an API call. My ultimate goal is to set the keys equal to the value I am getting from the API call.
def SomeFunction(key,val):
return APICall(val)
myDict = {'a' : 'A',
'b' : 'B',
'c' : 'C'
}
for key,val in myDict.items():
key = SomeFunction(key,val)
print a
#>>>'return value from API'
When I run this I get an error saying 'a' is not defined. I am struggling to understand why
key = SomeFunction(key,val)
does not instantiate the given key with the assignment of the return value from the API call.
Any help would be great.