passing variables between functions

how do i pass variables from one function to another in python?

Comments

  • : how do i pass variables from one function to another in python?

    Same way you passed them to the first function.

    [code]
    def func1(x, y):
    return func2(x, y, 1, 2)

    def func2(a, b, c, d):
    return a + b + c + d

    print func1(8, 9)
    [/code]


    [size=5][italic][blue][RED]i[/RED]nfidel[/blue][/italic][/size]

    [code]
    $ select * from users where clue > 0
    no rows returned
    [/code]

  • def function(x, y):
    total = x + y
    return total

    def main():
    a = 5
    b = 10
    total = function(a,b)
    print a, b, total

    main()

    By doing this you can pass args from main to a function and can get back any value by returning from that function.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories