python-crash-course/Chapter_08/8-08_user_albums.py
2025-02-21 14:45:39 +00:00

32 lines
1011 B
Python

# Exercise 8-8 User Albums
# Learning Objective: Write a function with a while loop that gathers input and returns a dictionary of information about an album.
# VERY MESSY
def make_album(artist_name, album_title, num_tracks=None):
album_info = {'artist': artist_name, 'album': album_title}
if num_tracks:
album_info['number_of_tracks'] = num_tracks
return album_info
while True:
print("Welcome, entering 'q' will quit this program... \n")
gathered_artist = input("Please enter your artist: ")
if gathered_artist == 'q':
break
gathered_album = input("Now enter the album name: ")
if gathered_album == 'q':
break
desired_info = make_album(gathered_artist, gathered_album)
print(desired_info)
'''
newAlbum = make_album('Korn', "Y'all wanna single", 1)
print(newAlbum)
newAlbum2 = make_album('Infected Mushroom', 'Classical Mushroom', 9)
print(newAlbum2)
newAlbum3 = make_album('Outsiders, Menog', 'Psychedelic Liquid')
print(newAlbum3)
'''