In this exercise, you’re going to finish coding a program that calculates how many years the user will have to wait until they can vote in Australia. The voting age in Australia is 18.
In the editor below, fill in the blanks (________
) so that the program asks for the age
of the user, works out how many years until they can vote, and print
the results back to the user. You will also need to fix this line of code as it contains an error (check the hint below if you can’t spot it):
years_remaining = 18 - age
Remember to use the Python reference sheet to help you with your code! Click on one of the buttons below:
Need some help? Click here to reveal a video walkthrough for this task!
age
to an integer.age
and the legal voting age (18 in Australia) and print
the result back to the user.age
will not be an integer by default, you will need to use the int()
command to convert it!Below is an example of how the program should run:
Please enter your name: Alice
Please enter your age: 14
Hi Alice! You have...
4
year(s) remaining before you can vote in Australia!