+ 6

Can I define a function within a function? If not explain why.

17th Apr 2019, 12:07 PM
Aditya Anupam
Aditya Anupam - avatar
6 odpowiedzi
+ 15
You can define a function inside another function. But you can only call it inside the function #1. It won't work if you call it outside your first function. # I hope this helps.
17th Apr 2019, 12:15 PM
🍇 Alex Tușinean 💜
🍇 Alex Tușinean 💜 - avatar
+ 6
https://code.sololearn.com/cvzo6jWb7Riv/?ref=app That's what happens in closures and decorators
17th Apr 2019, 12:48 PM
Anna
Anna - avatar
+ 5
Yes!!!!! Python allows you to do that!!!! I've made a code on python decorators which are the function-related concept in python Programming. https://code.sololearn.com/coIaUChlHV77/?ref=app here is a link to a webpage that may help you.It helped me a lot https://www.programiz.com/python-programming/closure
18th Apr 2019, 11:32 AM
Ayush Sinha
Ayush Sinha - avatar
+ 3
Nothing more to say. 🌲 Alex Tusinean 🔥 just explained all rules and stuff
17th Apr 2019, 11:33 PM
I‘m Sarah🌹
I‘m Sarah🌹 - avatar
- 1
You can define a function inside the function but u can only call it inside the function because outside the func it can't work... For more understable.... We all use calculator... In calculator we programmed it by inside function that's why we can add, sub, divide at a time by using calculator..... ##i hope this will help##
5th May 2019, 7:13 PM
Shashi Gupta
Shashi Gupta - avatar