def addAlbum(inDict, dbFilePath): name = input('Please enter the name of the album: ') while True: try: year = int(input('Please enter release year: ')) except: print('Year must be an integer!') continue break artist = input('Please enter the artist: ') newAlbum = Album(name, artist, year) while True: newSong = input('Please add a song or type "q" to stop: ') if (newSong == 'q'): break else: newAlbum.appendSong(newSong) if (newAlbum.getArtist() not in inDict): inDict[newAlbum.getArtist()] = [] inDict[newAlbum.getArtist()].append(newAlbum) else: albumFound = False for album in inDict[newAlbum.getArtist()]: if (album.getName() == newAlbum.getName()): albumFound = True if (albumFound): print('Album already exists! Aborting.') else: inDict[newAlbum.getArtist()].append(newAlbum) dict2File(inDict, dbFilePath)