Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions DAY54/jukebox_menu
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
from nested_data import albums

SONGS_LIST_INDEX = 3 # constants are represented by capital letters in python
SONG_TITLE_INDEX = 1
while True:
print("Please choose your album (invalid choice exits): ")
for index, (title, artist, year, songs) in enumerate(albums):
print("{}: {}".format(index + 1, title))

choice = int(input())
if 1 <= choice <= len(albums):
songs_list = albums[choice - 1][SONGS_LIST_INDEX] # here this [3] is used because songs are at index 3 in the list of albums
else:
break


print("Please choose your song: ")
for index, (track_number, song) in enumerate(songs_list): # unpacking ofa tuple
print("{}: {}".format(index + 1, song))

song_choice = int(input())
if 1 <= song_choice <= len(songs_list):
title = songs_list[song_choice - 1][SONG_TITLE_INDEX]

print("Playing {}".format(title))
print("=" * 40)