
Need more help with file handling?
In these tasks you have to use the skills learned in the previous exercises to create a new program based on the requirements below.
Write a program that:
- Defines two new functions to add singer & add band to the appropriate files.
- Reads and outputs the contents of the singers list and the bands list to the user.
- Asks the user if they want to input a new singer or new band (choose 1 for singer, 2 for band).
- Validates the input.
- Gets the user to input a singer or band that they want to add to the appropriate file, and passes that input into the appropriate function.
- Asks the user if they want to continue (c) or quit (q).
- Validates the input.
- Repeats asking the user if they want to continue, (c), or quit (q).
Help! My code doesn’t work
Make sure that you check for the following things:
- Include the file extension (
.txt
) in the file name
- Use the exact same file variable with
open
and in the loop.
- Use exactly the same case in the filename.
- Indenting all the code that should be inside loops.
- Close the file once task is completed.