Let's look at a new scenario. In the following code snippet, you will create a conditional statement that will check your age and let you know how you can participate in elections depending on that factor:
>>> age = 10
>>> if age < 18:
... print('You can follow the elections on the news')
... elif age < 35:
... print('You can vote in all elections')
... elif age >= 35:
... print('You can stand for any election')
...
You can follow the elections on the news
In this example, you use if
and elif
. The keyword elif
is short for "else if". So the code here is checking the age against different hard-coded values. If the age is less than 18, then the citizen can follow the elections on the news.
If they are older than 18 but less than 35, they can vote in all elections. Next you check if the citizen's age is greater than or equal to 35. Then they can run for any office themselves and participate in their democracy as a politician.