I’m currently on the Function lesson on Python. I kinda understand them (still learning but I’ll get there) but the thing I don’t understand is the “return” keyword that shows up in many examples. It isn’t explained anywhere and it’s really confusing me. I read a topic old 5 years explaining what it is, but I still don’t get it (this is the link to it if anyone wants to see: https://www.codecademy.com/en/forum_questions/51c0e35d7c82caace80008b1#answer-51c1a3059c4e9dd0fb00a7a0 ). If anyone has a better explanation, please leave a reply 'cause I’m still stuck on the same lesson for hours trying to understand.
Now for the functions calling functions part - there is also a lesson about that and it gives one example and a task which I don’t understand.
def fun_one(n): return n * 5 def fun_two(m): return fun_one(m) + 7
def one_good_turn(n): return n + 1 def deserves_another(n): return n + 2
Now this confused me a lot. In the first example they first defined a function “fun_one” and gave it a parameter with a name “n”. Then in the function “fun_two” it is being returned and has a parameter named “m”. I basicly don’t know what any of it means or what it does because if I run it, nothing visibly happens.
Then in the second example we have 2 functions.One returns n + 1, the other returns n + 2. In the task it says:
"Let’s look at the two functions in the editor: one_good_turn (which adds 1 to the number it takes in as an argument) and deserves_another (which adds 2).
Change the body of deserves_another so that it always adds 2 to the output of one_good_turn."
So, does that basicly mean it will take an input and then add 1 to it and make it so n = n + 1 then other function takes that n and adds 2 to it so it is like n = n + 2?