Chained function call
You can call multiple functions inside a single line.
Python: 3.0    Fatos Morina    03 Jul 2021   1
Login to upvote
1
2
3
4
5
6
7
8
def add(a, b):
    return a + b

def subtract(a, b):
    return a - b

a, b = 4, 5
print((subtract if a > b else add)(a, b)) # 9
Copy | Download as: .py file   PNG
Share on: FB   Twitter   LinkedIn   WA
©2021 - code108labs   Contributors   Hosted on DigitalOcean   Partner website: pythoncircle.com