Why Order Matters in Python
In World of Software Engineering, a player must first learn a spell from a class trainer before they can cast it.
If you tried to cast a spell you hadn’t learned yet, nothing would happen... the ability simply wouldn’t exist.
Python works in a similar way. It reads your program from top to bottom, in order. If you try to use something (like a function) before it has been defined, Python doesn’t know what you’re talking about... and the program will fail.
If you tried to cast a spell you hadn’t learned yet, nothing would happen... the ability simply wouldn’t exist.
Python works in a similar way. It reads your program from top to bottom, in order. If you try to use something (like a function) before it has been defined, Python doesn’t know what you’re talking about... and the program will fail.
Professional programs often use a main() function.
This is simply a central starting point.
All other functions are defined first.
Then main() is called at the very end.
This is simply a central starting point.
All other functions are defined first.
Then main() is called at the very end.
Your Mission:
The program below is broken because something is being called too early.
Rearrange the code so it runs correctly.
You can move the existing code around, but you probably shouldn't change any function contents.
The program below is broken because something is being called too early.
Rearrange the code so it runs correctly.
You can move the existing code around, but you probably shouldn't change any function contents.
Fix the execution order
main()
def main():
start_raid()
def start_raid():
print("The raid has begun!")