Nesting of conditional statements

What is «nesting of conditional statements?»

It means use a conditional function inside another conditional function. Sometimes we use this to reduce from a big quantity of data to just a few and then reduce again the number to get a value.

I will show you an example

Sorry, but my internet is slow at this moment 😦 i will let you the code here

school=input(«Which is your school?»)
age=int(input(«How old are you?»))
if school==»ITESM»:
if age==18:
print(«You are studying at ITESM and you are 18 y.o.»)
else:
print(«You are studying at ITESM»)
else:
print(«Wrong school»)

#the end

This code use a conditional inside a conditional to get a more exact value! that is the reason why we use nesteed conditionals.
I hope it was useful, anyway, i will let you a video link to learn more about the topic

 

 

 

 


Deja un comentario