Can we call function before or after the declaration of function in python ?? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
- 1

Can we call function before or after the declaration of function in python ??

15th Jun 2021, 7:00 AM
Yash Sharma
Yash Sharma - avatar
4 Answers
+ 8
we can only call the function after it has been created for exemple: def greeting(): print("Hi!") greeting() # Output: Hi! -------------------------------- greeting() def greeting(): print("Hi!") # Output: NameError more about functions here: https://www.w3schools.com/JUMP_LINK__&&__python__&&__JUMP_LINK/python_functions.asp 
15th Jun 2021, 7:03 AM
SammE
SammE - avatar
+ 5
Complete Python for beginners course at last it is being presented how to use functions Happy coding
15th Jun 2021, 7:17 AM
Atul [Inactive]
+ 4
Aside from Rostislav Khalilov 's great answer, which is correct if you call the function in global scope that is undeclared. But just an additional answer, if you call an another function inside the function (local scope) then you can call it even before the declaration. Example _____________ def first(): second() def second(): print("Second") >> Second _____________
15th Jun 2021, 7:17 AM
noteve
noteve - avatar
+ 4
Well it's same like I am giving you exam paper, and after exam I teach that topic! ;-) Why don't you try it by your own in code bits! :)
15th Jun 2021, 7:25 AM
Abhiyantā
Abhiyantā - avatar