Describe the difference between a chained conditional and a nested conditional.
Describe a strategy to avoid nested conditions. Give an example of a nested conditional that can be changed to a single conditional, and show the equivalent unique conditional
1
Expert's answer
2020-04-28T12:27:27-0400
cat = 1 #variable for cat
dog= 0 #variable for dog
#the nested will be
if(cat==1):
if(dog==0):
print("cat is 1 and dog is 0")
#Examples of code
if(cat==1 and dog==0):
print("cat is 1 and dog is 0")
#same result, less code
Comments
Leave a comment