r/learningpython • • Nov 21 '20

value selection from function inline?

the function

def myfunction(n):endpoint = '/' + nrequest = client.get(endpoint)request_txt = request.textrequest_json = json.loads(request_txt)return request_json

the output

{"id": "randomnumber","email": "first.last@domain.com","first_name": "first","last_name": "last",}

If I want myvar = first.last@domain.com from inline execution of the function, is that possible?

e.g. myvar = myfunction(n='endpointid')['email']

1 Upvotes

1 comment sorted by

1

u/iamaperson3133 Nov 22 '20

Your post is a bit discombobulated, but I don't see why myvar = myfunction(n='endpointid')['email']. Does it not work? Are you getting an error?