I think this will be probably one of the most dumbests questions of all, but i'm not really understading very well the functions and one thing is about the use of "return"
So, let's imagine the simple example that I want to greet my function (by saying "Hi function!") and use a function for that.
So should I use the print statement in the function like this:
def hello_func (greeting):
print (f'{greeting} function!')
greeting = 'Hi'
hello_func(greeting)
Or should I return the value in the function:
def hello_func (greeting):
return (f'{greeting} function!')
greeting = 'Hi'
print (hello_func(greeting))
The output is the same (Hi function!)... so in this particular case it doesn't matter what I use or is there a "better" code?
Thank you.
hellostr = hello_func(greeting)and use it later. Make functions "pure", and separate out the IO functions (likeprint).