I’m reading about nested tuples at the moment and trying a very simple one. Can someone point out to where I’m going wrong?
albums = ("Backstreet Boys", "1991",
[("No place"), ("Backstreet's Back"), ("Everybody")])
for artist,year,songs in albums:
print("Artist: {}\nYear:{}\nSongs: {}".format((artist,year,songs)))
Thanks for the help, everyone. 🙂
>Solution :
You need to wrap the albums tuple in a list and remove the brackets in the format command.
albums = [("Backstreet Boys", "1991",
[("No place"), ("Backstreet's Back"), ("Everybody")])]
for artist,year,songs in albums:
print("Artist: {}\nYear:{}\nSongs: {}".format(artist,year,songs))
That is because xou try to iterate through the tuple albums, not a list of tuples.