Bring the data center back online
A power outage has left six servers in different states. Write a recovery script that checks each server before choosing a command. Healthy servers must stay online without being touched.
What the game provides
servers is a list of dictionaries. Each server has a "name" and a "state", for example:
{"name": "web-01", "state": "error"}
The game also provides two functions. Pass the server dictionary to the command, not its name:
restart(server)
power_on(server)
You do not need to define these functions or create your own servers list.
Your task
Complete the supplied for loop using if and elif:
"error": Call restart(server) once.
"off": Call power_on(server) once.
"running": Do nothing. There is no need for an else branch.
Replace both pass lines with the correct commands. Read server["state"] to make each decision, and leave the dictionaries and supplied functions unchanged. Do not hard-code server names or positions.
Run your recovery script
Each attempt starts with two error-state servers, two off servers, and two running servers. Their positions change between attempts. The game freezes that arrangement while your code runs, then plays back the results one server at a time.
A restart briefly takes a faulty server dark before its amber startup light turns green. A powered-on server changes from dark to amber to green. A healthy server gets an “Already running” check without a restart.
Incorrect commands leave the affected server unchanged and display a warning. Repeated commands and unnecessary commands on healthy servers are mistakes. There is no countdown, so take your time editing.
Success
Bring all six servers online without any wrong or unnecessary command. Your code must also use a for loop with an if/elif decision and work on additional server lists with different names, lengths, and state arrangements.
If you click Run while playback is active, only your latest queued code runs next. The current animation finishes without changing its rules, and a superseded attempt cannot award completion.
Hint
The first branch handles "error". The elif branch handles "off". When neither condition matches, Python moves to the next server.