can someone give me an example of when we would use nested if statements? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

can someone give me an example of when we would use nested if statements?

just trying to wrap my head around if statements

13th Feb 2020, 6:51 PM
Maheen Hassan
Maheen Hassan - avatar
2 Answers
+ 4
when you have to check something that depends on another thing if age > 18: if > male: do something you can also use && or || which is ā€œandā€ ā€œorā€
13th Feb 2020, 7:17 PM
āœ³AsterisKāœ³
āœ³AsterisKāœ³ - avatar
+ 3
It is used when you want to have a condition after passing a condition. For example if a want to test a number if it is less than 100 and even if num < 100: if num%2==0: print("Yeah") else: print("Nope") else: print("Nope") However, you rarely do this. Using and/or etc is much better. It's all explained in the tutorial. Please complete it.
13th Feb 2020, 7:10 PM
XXX
XXX - avatar