Created
July 24, 2022 15:52
-
-
Save kadirmalak/72649d20bd8297f46850d620bdac62db to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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