I am going through the book 'Python Crash Course' and the problem is as follows:
8-8. User Albums: Start with your program from Exercise 8-7 . Write a while loop that allows users to enter an album’s artist and title . Once you have that information, call make_album() with the user’s input and print the dictionary that’s created . Be sure to include a quit value in the while loop .
I did 8-7 no problem, but trying to add the functionality, the loop to solve 8-7 I can't figure out.
Here was the code I already tried:
while True:
print('Give me an artist.')
artist=input()
print('Give me an album.')
album=input()
if artist == 'quit':
break
elif track_no:
track_no=input()
albums = {'Artist': artist, 'Album':album, 'Track Number':track_no}
else:
albums = {'Artist': artist, 'Album':album}
print(albums)
Here is my code from the 8-7 problem:
def make_album(artist, album, track_no=' '):
if track_no:
albums = {'Artist': artist, 'Album':album, 'Track Number':track_no}
else:
albums = {'Artist': artist, 'Album':album}
print(albums)