- 1
Can we call function before or after the declaration of function in python ??
4 odpowiedzi
+ 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
+ 5
Complete Python for beginners course at last it is being presented how to use functions
Happy coding
+ 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
_____________
+ 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! :)