My question exactly is i want to use function output as input to another function,
Like:
def first(one,two):
#some codes gives me info from json files
api_data = json.loads(api.text)
return api_data["response"]["info"][one][two];
def second(moreinfo):
#this code is using first function and gives me the result to do something else on it, beside i want the first function as it is, because i'm using it in the project.
api_data = json.loads(api.text)
return api_data[moreinfo]["data"]["name"];
I'm using this in the file to get the result from second function
second(""+str(first(one,"two"))+"")
And i got this error
return api_data[first(one,"two")]["data"]["name"]
KeyError: 'data'
I think this error because first(one,"two") in second function doesn't took, because i tried to put
return api_data["1"]["data"]["name"]
And its work with giving me info for number 1 result from first function,
Thanks and Regards :)
EDITED
Some examples for json
(for first function)
{
"response": {
"info": [
{
"id": 1,
"desc": "desc"
}
]
}
}
Second example (i want to print this in second function)
{
"1": {
"data": {
"name": "Name"
}
}
}
api_data?api_datacontents?second(str(first(one,"two")))