What’s the difference from printing a function and calling a function in Python? [duplicate]

  function, printing, python, return

I am a little confused why the return statement won’t work if I’m calling a function but will when I am printing it. Below is the example of code I worked with.

def get_favorite_food(): 
     food = input("What's your favorite food?")
     return 'Your favorite food' + ' ' + food + ' ' + 'is ready!'

When I try to run:

get_favorite_food()
>>>
Whats your favorite food?Macaroni

Compared to:

print(get_favorite_food())
>>>
Whats your favorite food?Macaroni
Your favorite food Macaroni is ready! 

I apologize if I am using incorrect phrasing in my question. Please correct me so I could rephrase the question for myself and others!

Source: Python Questions

LEAVE A COMMENT