Using a variable outside of function in Python

后端 未结 4 1144
误落风尘
误落风尘 2021-01-03 08:18

A really simple question, and I\'m sure I knew it but must have forgotten

When running this code:

x = 0
def run_5():
    print \"5 minutes later\"
           


        
4条回答
  •  醉梦人生
    2021-01-03 09:02

    I think you need to define a variable outside the function, if you want to assign it a return value from the function.

    The name of the variable can be different than the name in function as it is just holding it

提交回复
热议问题