So far we’ve seen how to use loops, while and for loops. And we’ve learned that they are very useful in almost any program we want to do. But there will be a time when our programms become complex when we will want to evualte a condition if another turn out to be true, an example:

if variable < 200:

if variable == 150:

do something

elif variable == 100:

do something

else:

do something

else variable > 200:

do something

 

We can see how in here we evalate if our variable was in range below 200 and then if it had exactly the value of 150 and then of 100, if non of there were true we also state something.

This is what nested conditionals work for.

 

 

 

 

 

 

CC BY 4.0 Nesting conditionals by fersabal is licensed under a Creative Commons Attribution 4.0 International License.