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-05-01T14:44:37-0400
a = 1
b = 2
if a == 1:
if b == 2: #It will only be executed if a = 1
print('Yes')
if a == 1 and b == 2:
print('Yes') #It will only be executed if (a = 1 AND b = 2)
Comments
Leave a comment