Class Register


Learning Objectives

In this challenge we are going to focus on accessing a text file in Python to:

  • Read the content of the file line by line,
  • Write data to a new file.

Before completing this challenge, you should read about the main file handling operations using Python.

To complete this challenge we recommend you to use Coding Ground which let you code online and use multiple files. You will first need to create a text file to copy the content of the class list (from the text file given below)


Your Challenge

Your challenge consists of writing a Python script that could be used by a teacher to take the register at the beginning of the lesson.

Your program will need to:

  1. Read the text file called classList.txt, line by line.
  2. For each student (line of the text file) the program should ask the teacher if the pupil is pesent (“/” code), absent for medical reasons or illness (“M” code), on a school trip (“T” code), or absent with no reason provided yet (“X” code).
  3. The program should store the teacher’s input alongside with the name of each pupil into a new text file called “register.txt”.

To complete this challenge you will need to use the class list text file:




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 1.3 / 5. Vote count: 9

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

As you found this challenge interesting...

Follow us on social media!