Completed Exercise 8-8 User Albums
This commit is contained in:
parent
6d5878c8ac
commit
151d5d6ae1
32
Chapter_08/8-08_user_albums.py
Normal file
32
Chapter_08/8-08_user_albums.py
Normal file
@ -0,0 +1,32 @@
|
||||
# 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)
|
||||
'''
|
||||
Loading…
x
Reference in New Issue
Block a user