How can we reference the right index if all our lists are seperate?

Hi, Thank you. It worked. I was trying different things before I posted here. ‘i’ incremented accidently. The problem was with print statement not being in the loop.

1 Like

Good for us it had no effect upon the actual iteration variable.

1 Like

Hi,
Thank you for your contribution. I was wondering if there’s a difference between doing what you suggested and doing it with a counter. i.e.

counter = 0
for x in highlighted_poems_details:
print(“The poem {title} was published by {author} in {date}”.format(title = titles[counter],author = poets[counter],date = dates[counter]))
counter += 1

Thanks again for all your help.

So long as you are using the same index for all three lists, the code will produce expected results.

Did anyone struggle hard with 10? I just couldn’t think of the answer and quit and looked up the explanation here. Range and length didn’t occur to me at all. I’m wondering if I should stop learning because it’s just not soaking in for my poor brain. Once I see the answer, I go ah yes I can see and understand how that works, but it doesn’t occur to me before at all =(

We learn by stumbling, a lot. If you are picking up any bits then count yourself in. It is a sign you are well suited to this. Don’t expect it to be easy, though. It will be a lot of the same plateau that led to your question in the first place. Now you know the answer for each of those instances.

1 Like

Thanks mtf for the encouragement! You’re a real mvp :slight_smile:

1 Like

For the sake of efficiency, would it be better to bypass the creation of the titles, poets, and dates lists?

for poem in highlighted_poems_details:
  print('The poem {title} was published by {poet} in {date}.'.format(title=poem[0], poet=poem[1], date=poem[2]))

I’m just curious if solving in the way I have here is not following best practice or might cause problems in the future?