"""Display a music catalog, then select a playlist from several albums."""

songs = [('Vienna', 5), ('Evangeline', 3), ('Stick Season', 4)]
play_counts = [2, 0, 5]

# Display the library.
total = 0
for title, minutes in songs:
    total += minutes
labels = [f'{title} ({minutes} min)' for title, minutes in songs]
rows = [f'{label}: {count} plays' for label, count in zip(labels, play_counts)]
for number, row in enumerate(rows, start=1):
    print(number, row)
print('Total:', total, 'min')

# Select songs within each album, then combine them into one playlist.
album_names = ['Favorites', 'Live', 'Unsorted']
albums = [
    songs,
    [('Evangeline', 6), ('Beautiful Things', 2)],
    [],
]
limit = 4
short_by_album = [
    [title for title, minutes in album if minutes <= limit]
    for album in albums
]
playlist = [title for group in short_by_album for title in group]
counts = {name: len(group) for name, group in zip(album_names, short_by_album)}
for number, title in enumerate(playlist, start=1):
    print(number, title)
print(counts)
