Python: Passing variables between functions

后端 未结 6 1256
庸人自扰
庸人自扰 2020-11-27 11:41

I\'ve spent the past few hours reading around in here and elsewhere, as well as experimenting, but I\'m not really understanding what I am sure is a very basic concept: pass

6条回答
  •  野趣味
    野趣味 (楼主)
    2020-11-27 12:35

    passing variable from one function as argument to other functions can be done like this

    define functions like this

    def function1():
    global a
    a=input("Enter any number\t")
    
    def function2(argument):
    print ("this is the entered number - ",argument)
    

    call the functions like this

    function1()
    function2(a)
    

提交回复
热议问题