Skip to content

Instantly share code, notes, and snippets.

@kadirmalak
Created July 24, 2022 15:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kadirmalak/72649d20bd8297f46850d620bdac62db to your computer and use it in GitHub Desktop.
Save kadirmalak/72649d20bd8297f46850d620bdac62db to your computer and use it in GitHub Desktop.
import json
my_songs = [
{
'title': "Olurum sana",
'artists': ["tarkan"]
},
{
'title': "nothing else matters",
'artists': ["metallica"]
},
{
'title': "stairway to heaven",
'artists': ["led zeppelin"]
},
{
'title': "desert rose",
'artists': ["sting", "mahmud fahradi"]
}
]
#print(my_songs[3]['artists'][1])
#for song in my_songs:
# print(song)
myfile = open("my_collection.txt", "w")
def write_song(song, f):
f.write(json.dumps(song))
f.write("\n")
for song in my_songs:
write_song(song, myfile)
myfile.close()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment