# This program allows the user to create a playlist of their favorite songs. #
def playlist():
fav_songs = input('enter a song name: ')
fav_songs_list.append(fav_songs)
song_length = input('What is the length of your song (enter a number only): ')
song_length_list.append(song_length)
from datetime import date
num_songs=0
fav_songs_list = []
fav_songs_dict = {}
song_length_list = []
fav_songs_file = open("new_file.txt", 'w+')
fav_songs_read_file = fav_songs_file.read()
fav_songs_date = date.today()
while True:
var_fav = input("do you want to add to your playlist (Yes or No): ")
if var_fav == "Yes":
playlist()
elif var_fav == "No":
break
# The playlist is finished #
else:
pass
# create dictionary
songs_dict=dict(zip(fav_songs_list,song_length_list))
print("You song list dictionary is" , songs_dict)
# create favorite song list file
fav_songs_file.write('fav_songs_dict')
print("Your song list is" , fav_songs_list)
print("The length of your songs in your list are", song_length_list)
sum = 0
for length in song_length_list:
sum += float(length)
for num in range(1, len(fav_songs_list)):
num_songs = num+1
print("The length of your playlist is" ,sum, "minutes")
print("There are", num_songs, "songs in your playlist")
print("This playlist was saved on" ,fav_songs_date)
fav_songs_file.close()