What does return do? Nothing is ever returned

后端 未结 4 1995
[愿得一人]
[愿得一人] 2020-12-04 04:06

I have been learning Python for some days now. However, I do not understand return. I have read several explanations from my textbooks and online; they don\'t help!

4条回答
  •  庸人自扰
    2020-12-04 04:38

    You either need to add a print or write the whole thing into the interactive interpreter to see the return value.

    return makes it possible to get some output/result out of a function. To this value later in the code you have to assign it to a variable:

    a = sqrt(25)
    

提交回复
热议问题