should the functions be defined before it is used? but why the following code works:
def main():
dog()
def dog():
print("This is a dog.")
if __name__ == '__main__':
main()
I mean the dog() is defined after it is called, how this works?
Actually it's not (defined after it's called). This script will do the following:
At that point dog is already known in global scope and main can call it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With