Kings & Queens of England

Portrait of Henry VIII
Portrait of Henry VIII

There have been 66 monarchs of England and Britain spread over a period of 1500 years.

For this Python challenge you will use a text file listing all of these monarchs in chronological order. You will then write a Python program to prompt the user to enter a year (between 757 and 2017) and your program will look up for the name of the monarch of England at the given date.

To complete this challenge you will need to read more about how to read through a CSV file.

The text file we will use contains one line per monarch. On each line it stores the year the reign started, the year it ended and the name of the monarch as follows:


Complete the Code


Once you have completed the code check that it produces the expected output by performing the following tests:

Test # Input Values Expected Output Actual Output
#1 1192 Richard I
#2 1345 Edward III
#3 1042 Harthacanut
Edward the Confessor
#4 1547 Henry VIII
Edward VI
#5 1016 Ethelred II the Unready
Edmund lronside
Cnut (Canute)
#6 512 Not Found

Extension Task:

Tweak the output of your program so that when giving the name of the monarch matching the year entered, your program also mentions who were the previous monarch and the next monarch.

For instance the output of the program could be:

In 1192, the monarch of England was Richard I. Their predecessor was Henry II up until 1189 and their successor was John whose reign started in 1199.

Video Tutorial



The solution for this challenge is available to full members!
Find out how to become a member:
➤ Members' Area

Did you like this challenge?

Click on a star to rate it!

Average rating 4.6 / 5. Vote count: 18

No votes so far! Be the first to rate this post.

As you found this challenge interesting...

Follow us on social media!

Tagged with: , ,