FAQ: String Methods - Review

Was it a bug that I got a check-mark on this?

#print(highlighted_poems)

highlighted_poems_list = highlighted_poems.split(',')
#print(highlighted_poems_list)

highlighted_poems_stripped = []
for poem in highlighted_poems_list:
  x = poem.strip()
  highlighted_poems_stripped.append(x)
#print(highlighted_poems_stripped)

highlighted_poems_details = []
for poems in highlighted_poems_stripped:
  x = poems.split(':')
  highlighted_poems_details.append(x)
#print(highlighted_poems_details)

titles = []
poets = []
dates = []
for details in highlighted_poems_details:
  titles.append(details[0])
  poets.append(details[1])
  dates.append(details[2])

for poems in highlighted_poems_details:
  for i in range(len(highlighted_poems_details)):
    print("The poem "+titles[i]+" was published by "+poets[i]+" in "+dates[i]".")

Upon running this code, I get:

File "script.py", line 30
    print("The poem "+titles[i]+" was published by "+poets[i]+" in "+dates[i]".")
                                                                               ^
SyntaxError: invalid syntax

And the lesson clears.

EDIT: I know I’m missing a “+” and that it won’t print correctly, solved this after the fact, but I wanted to submit this because I think it’s weird that the course cleared me. You’ll find what I went with at the last step below.

for i in range(len(titles)):
  print("The poem {title} was published by {poets} in {dates}.".format(title=titles[i], poets=poets[i], dates=dates[i]))