One strategy for avoiding nested condition is by using functional statements that layer in different functions. Also another one is to use operators 'and' 'or' and 'not' to give the conditional statements greater flexibility which allows fewer nested conditionals.
# nested conditiona
Number = 4;
if ( Number > 0 ):
if ( Number%2==0):
print("Positive even number ")
# single conditional
Number = 4;
if ( Number > 0 and Number%2==0 ):
print("Positive even number")
Comments
Leave a comment