Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Passing return value to function

I’m having difficulty understanding how to use return values.

def grab_name(string):
    return grab("users/self/profile", string)

    def print_user_info(arg):
        print(grab("users/self/profile", "janice"))

I need to consume the result of passing the first function in order to print the user info. But I’m not sure how to do that…the second function is not supposed to consume a string or call the function directly. I understand the return value doesn’t exist outside the scope of the first function so I don’t understand how to get the value into the second function without just calling it directly as I have above.

The first function is basically returning a dictionary and the second function needs to consume the result of calling the first function.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

I think this small modification is what you are seeking.

def grab_name(string):
    return grab("users/self/profile", string)

def print_user_info(arg):
    print(grab_name("janice"))
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading