0

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.

2
  • 2
    you should keep in mind anything after return is not gonna be printed Commented Oct 10, 2022 at 16:21
  • you want to take the values from the first function and take them to the second function ???? Commented Oct 10, 2022 at 16:22

2 Answers 2

3

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"))
Sign up to request clarification or add additional context in comments.

Comments

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

def print_user_info(arg):
    return "janice"
    
print(print_user_info(grab_name))  

result :

janice

1 Comment

As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.