HOME/Articles/

python code chained function call (snippet)

Article Outline

Python example 'python code chained function call'

Functions in program:

  • def subtract(a, b):
  • def add(a, b):

python code chained function call

Python code example: python code chained function call

#Use chained function call

def add(a, b):
    return a + b
def subtract(a, b):   
    return a - b
a, b = 5, 10
print((subtract if a > b else add)(a, b))

More Python: https://pythonprogramminglanguage.com