When a script fails, Python prints a traceback.
You read it from the bottom, first the error and then the file and the line:
Figure 1 - A Traceback Is Read from the Bottom
The name of the error tells you what to look for: a
KeyErroris a key that does not exist and aNameErroris a variable that does not exist.In the lab, run the script and read the traceback.
Fix the line of the error to get the flag.Answer the question below
Enter the flag you obtained.
An error stops the script, even when the other switches are fine.
Withtryandexcept, the script handles the error and continues:
Figure 2 - except Runs Only When the Error Happens
After
except, you write the name of the error that you expect.In the lab, the script stops at SW2 because it has no port.
Usetryandexceptto printSW2 has no portand continue with SW3 to get the flag.Answer the question below
Enter the flag you obtained.