M
M
Maxim Siomin2020-06-17 10:45:21
Python
Maxim Siomin, 2020-06-17 10:45:21

Is it possible to create a function inside a function?

Will the code work:

def func1():
    def func2():
        print('Hello, world')
func2()

Answer the question

In order to leave comments, you need to log in

1 answer(s)
V
Vladimir Kuts, 2020-06-17
@MaxSiominDev

Is it possible to create a function inside a function?

yes - you can
Will the code work:

no -
func2 won't be visible in the global scope because you defined it inside func1

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question