Chained conditionals are simply a "chain" or a combination or multiple conditions. We can combine conditions using the following three key words:
The and keyword allows us to check if two conditions are true. If they are both true then the entire condition is true. If one or both of them are false then the entire condition is false.
The or keyword allows us to check if one of two conditions is true. If one or both of the conditions are true then then entire condition will be true. If both of the conditions are false then the entire condition is false.
The not keyword allows us to check if an entire condition is false. If the condition is false it will result in a true value. If the condition is true it will give us a false value (you can think of it as reversing the condition).
We can also combine the use of these keywords to create longer conditions:
Of course we can combine this with our knowledge of if statements to check multiple conditions in one if:
Now that we've learned about some basic logic and control structures in python we can move on to nesting. Nesting is simply putting code inside of other code. For example placing an if statement inside of an already existing if statement.
There is no limit to the amount of times that we can nest. We just have to be sure that we are aware of our indentation.