Storing user inputs as parameters for a function

57 Views Asked by At

Does this work? I'm trying to write a while loop that allows users to enter an album's artist and title. Once I have that information, I can call the function make_album with the user's input and print the dictionary that's created. I also need to include a quit value in the while loop.

Here is my code:

def make_album(name, title, number = None):
    """Return a dictiomary containing artist name and album title"""
    dictionary = {}
    dictionary["Artist"] = artist_name
    dictionary["Title"] = album_title
    dictionary["Number of songs"] = song_number   
    print_dict = print(dictionary)
    return print_dict 


while True:
    artist_name = input("\nPress 'q' to quit. \nWhat is the name of your favorite artist? ")
    if artist_name == 'q':
        break

    album_title = input("\nPress 'q' to quit. \nWhat is the title of your favorite album? ")
    if album_title == 'q':
        break

    song_number = input("\nPress 'q' to quit. \nHow many songs are in your favorite album? ")
    if song_number == 'q':
        break
   
    make_album(artist_name, album_title, song_number)

    another_entry = input("Would you like to input another entry? (yes/no) ")
    if another_entry == "no":
        break
0

There are 0 best solutions below