PCEP Control Flow, Loops, Lists and Logic • Set 5
PCEP Control Flow, Loops, Lists and Logic Practice Test 5 — 15 questions with explanations. Free, no signup.
You are working on a network automation script that reads a configuration file containing firewall rules. Each rule is a dictionary with keys 'source_ip', 'dest_ip', 'action'. The script must iterate over the rules and print all rules where action is 'allow'. However, the script is not printing any output even though there are allow rules in the file. The code snippet is:
rules = [{'source_ip':'10.0.0.1','dest_ip':'10.0.0.2','action':'allow'},
{'source_ip':'10.0.0.2','dest_ip':'10.0.0.3','action':'deny'}]
for rule in rules:
if rule('action') == 'allow':
print(rule)What is the most likely cause of the problem?
Choose an answer to begin — your selection is scored in the full session.
15 questions · instant feedback and full explanations after every question.