python print value of foreign key

i want to print the album id, album name, and artist name in this function

    print("--album list--")
    for album in albums:
        print(f"id: {album[0]}, {album[1]}") #add  artist name to print statement
    print("---- \n")

artist:                         albums:
artist_id, artist name          album_id, album_name, artist_id

if we have

1, metallica                   1, ride the lightning, 1
2, megadeth                    2, rust in peace, 2

the above function will print:

id: 1, ride the lightning
id: 2, rust in peace

what i would like is

id: 1, ride the lightning, metallica
id: 2, rust in peace, megadeth


Read more here:

Content Attribution

This content was originally published by Jason Antonucci at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: