1with open('output.txt', 'w') as file: # Use file to refer to the file object
2
3 file.write('Hi there!')
1with open('songs.txt') as f,open('songs_out.txt', 'w') as f_out:
2 for line in f:
3 line = line.strip()
4 if line.startswith("#EXTINF"):
5 f_out.write(f'{line}\n')
6 name = line.split(",")[1]
7 f_out.write(f'{name}.mp3\n')
8