Question: Step 2 : Create an if / elif / else function. What if we have more than two conditional statements to consider? In this case,
Step : Create an ifelifelse function.
What if we have more than two conditional statements to consider? In this case, we can use elif statements in the middle of the ifelse function. An elif statement is evaluated if the if statement is false and before the else statement. You can have as many elif statements as you would like. However, the first one matched will be executed and none of the remaining elif statements will be checked. Nor will the else statement.
The script in the following example asks the user to input the number of an IPv ACL and then checks whether that number is a standard IPv ACL, extended IPv ACL, or neither standard or extended IPv ACL. a Create this script for your files. Open a blank script and save it as ifacl.py Copy the script into the file.
aclNum intinputWhat is the IPv ACL number? if aclNum and aclNum :
printThis is a standard IPv ACL." elif aclNum and aclNum :
printThis is an extended IPv ACL." else:
printThis is not a standard or extended IPv ACL."
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
