Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- song_dictionary = {
- 'song1': {'title': 'Bad Day',
- 'artist': 'Daniel Powter',
- 'album': ['Daniel Powter'],
- 'release_date': 2005,
- 'genre': ['Pop']}
- }
- def add_song(song_title, song_artist, album, release_date, genre):
- dict_count = len(song_dictionary) + 1
- song_dictionary['song' + str(dict_count)] = {'title': song_title,
- 'artist': song_artist,
- 'album': [album],
- 'release_date': release_date,
- 'genre': [genre]}
- def print_all_unique_genre():
- # Extracting unique genres
- unique_genres = set()
- for movie_info in song_dictionary.values():
- unique_genres.update(movie_info.get('genre', []))
- # Printing unique genres
- print('Unique Genres:', unique_genres)
- def print_all_unique_albums():
- # Extracting unique genres
- unique_albums = set()
- for movie_info in song_dictionary.values():
- unique_albums.update(movie_info.get('album', []))
- # Printing unique genres
- print('Unique Albums:', unique_albums)
- def print_album_songs():
- # Extracting unique genres
- unique_genres = set()
- for movie_info in song_dictionary.values():
- unique_genres.update(movie_info.get('genres', []))
- # Printing unique genres
- print('Unique Genres:', unique_genres)
- def print_title_artist_date():
- for song_id, song_info in song_dictionary.items():
- title = song_info['title']
- artist = song_info['artist']
- release_date = song_info['release_date']
- print(f"{title}\t{artist}\t{release_date}")
- def print_song_released_after_2010():
- # Print song titles released after the year 2010
- for song_id, song_info in song_dictionary.items():
- title = song_info['title']
- release_date = song_info['release_date']
- # Check if the release year is known and greater than 2010
- if release_date > 2010:
- print(f"{title} (Released in {release_date})")
- print(song_dictionary)
- print('--------------------------------------------------------------------------------------')
- add_song('Adore You', 'Harry Styles', 'Fine Line', 2019, 'Funk, Disco, Pop Rock')
- add_song('A Thousand Miles', 'Vanessa Cariton', 'Be Not Nobody', 2002, 'Pop')
- add_song('Lover', 'Taylor Swift', 'Lover', 2019, 'Country, Indie Folk, Alternative Country')
- print(song_dictionary)
- print_all_unique_genre()
- print_all_unique_albums()
- print_title_artist_date()
- print_song_released_after_2010()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement