Lewis
Lewis

Reputation: 19

how to use a function to call other functions

Excuse me, i am a beginner to learn python. I want to create a function to call other functions by python.

this is my logic:

def1(parameters1):
    variable1 
    return variable1
def2(parameters2):
    variable2 
    return variable2
def3(parameters3):
    variable3 
    return variable3

finally def4 can call def1,def2,def3

How to do it? What articles I can read them?

Upvotes: 0

Views: 129

Answers (1)

JTunis
JTunis

Reputation: 161

First, you'll need to define your functions slightly differently. They should look like the following:

def func1(parameters1):
    variable1 
    return variable1

def func2(parameters2):
    variable2 
    return variable2

def func3(parameters3):
    variable3 
    return variable3

You can then call those functions like this:

def func4(input):
    variable_1 = func1(input)
    variable_2 = func2(variable_1)
    variable_3 = func3(variable_2)
    return variable_3

Upvotes: 1

Related Questions