O'Reilly logo
  • Longxiang Lyu thinks this is interesting:

8-8. User Albums:


Cover of Python Crash Course


def make_album(album_title, artist_name, track_no = -1):
"""collect album info"""
album = dict(title=album_title.title(), artist=artist_name.title())
if track_no != -1:
album['track_count'] = track_no
return album

print(make_album('Love can', 'David Tao'))
print(make_album('Phantom of Opera', 'unknown', 12))

def main_loop():
albums = []
while True:
cont = raw_input('\nCollect album info, press y/Y to continue...')
if cont != 'Y' and cont != 'y':
t = raw_input('Please enter album t...