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,
- Append data at the end of the file,
- Write into a new text file.
To complete these challenges 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 playlist (from the text file given below)
Your first challenge consists of writing a Python script that will read the following text file, one line at a time and display the content of each line on screen.
As you are willing to complete this challenge we assume that you already have some good Python skills. To learn more about accessing text files in Python, you will first need to do some research on the Internet.
Your second challenge consists of opening the text file with Python in “write” mode to add the following song at the end of the playlist:
“Happy” by Pharrell Williams – Duration: 3:52
You will need to research the Intenet on how to write at the end of a text file.
For your third challenge you will edit the playlist so that the song “Happy” by Pharrell Williams appear in third position.