How to define function inside a function in Python

1 Answer

0 votes
def get_max_and_sum(a, b, c):
    def max_a_b_c():
        return max(a, b, c)

    def sum_a_b_c():
        return a + b + c

    return max_a_b_c(), sum_a_b_c()

x, y = get_max_and_sum(4, 9, 7)

print("Max: {0}, Sum: {1}". format(x, y))
   
   
   
   
   
'''
run:
   
Max: 9, Sum: 20
   
'''

 



answered Feb 19, 2023 by avibootz

Related questions

...