My mp3 playlist

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,
  • 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)

codingground

Challenge #1


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.


TextFile
My Playlist.txt


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.

Challenge #2


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.

Challenge #3


For your third challenge you will edit the playlist so that the song “Happy” by Pharrell Williams appear in third position.

Did you like this challenge?

Click on a star to rate it!

Average rating 1.8 / 5. Vote count: 5

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

As you found this challenge interesting...

Follow us on social media!

Tagged with: ,