In the last lesson I discussed conditional statements using the if-else keywords, but what is you want to create a nested if statements so different variables can produce different results
You can then use the if...elif...else or as is can also be called nested if statement.
So rather then writing code like
Code:
Output:
Here's how to write it:
Code:
An example of a practical application of this is a code I wrote in the GPA calculator post.
Here it shows different outputs for different conditions fulfilled.
NOTE:You can also use boolean operations in and if else statement an example is
Hope you enjoyed this lesson, thanks for reading, like, share, comment, next post will be available next week.
Top comments (0)