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 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:
- Read the text file called classList.txt, line by line.
- 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).
- 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: