How to return a value from a function?

前端 未结 5 1013
Happy的楠姐
Happy的楠姐 2021-01-28 21:39

Yes, I\'ve read tons of examples on this but I still don\'t get it.

I\'m learning Python and I made this script in order to help me understand how to \'return\':

5条回答
  •  囚心锁ツ
    2021-01-28 21:56

    I'm not a python programmers, but this looks like a problem of scope. You did define the variable "random" but it's scope-- the section of the code where it is visible and usable-- is limited to the function where you define it. In this case, inside the random_number() function.

    It is not visible inside the calc_pay_rise() function.
    What is visible is the other function, random_number() itself. That is what you need to use in your addition.

    That is the basic point of returning values.

提交回复
热议问题