Modifying function arguments

后端 未结 3 1260
鱼传尺愫
鱼传尺愫 2020-11-30 14:29

Sorry if this is a dumb question, but I\'ve looked for a while and not really found the answer.

If I\'m writing a python function, for example:

def f         


        
3条回答
  •  眼角桃花
    2020-11-30 14:57

    If you are looking to modify the value of the variables you could have your code be

    def func(a,b):
        int1 = a + 2
        int2 = b + 3
        return int1,int2
    
    a = 2
    b = 3
    a,b = func(a,b)
    

    This allows you to actually change the values of the a and b variables with the function.

提交回复
热议问题