Help to understand please.
If i use list concantinashion (+=), not .append we get:
highlighted_poems_list = ['Afterimages:Audre Lorde:1997', ' The Shadow:William Carlos Williams:1915']
highlighted_poems_stripped = []
for item in highlighted_poems_list:
highlighted_poems_stripped += item .strip()
print(highlighted_poems_stripped)
[‘A’, ‘f’, ‘t’, ‘e’, ‘r’, ‘i’, ‘m’, ‘a’, ‘g’, ‘e’, ‘s’, ‘:’, ‘A’, ‘u’, ‘d’, ‘r’, ‘e’, ’ ', ‘L’, ‘o’, ‘r’, ‘d’, ‘e’, ‘:’, ‘1’, ‘9’, ‘9’, ‘7’, ‘T’, ‘h’, ‘e’, ’ ', ‘S’, ‘h’, ‘a’, ‘d’, ‘o’, ‘w’, ‘:’, ‘W’, ‘i’, ‘l’, ‘l’, ‘i’, ‘a’, ‘m’, ’ ', ‘C’, ‘a’, ‘r’, ‘l’, ‘o’, ‘s’, ’ ', ‘W’, ‘i’, ‘l’, ‘l’, ‘i’, ‘a’, ‘m’, ‘s’, ‘:’, ‘1’, ‘9’, ‘1’, ‘5’]
But, item[0] in is not a single letter, item [0] is Afterimages:Audre Lorde:1997.
print(highlighted_poems_list[0])
Afterimages:Audre Lorde:1997
OR:
for item in highlighted_poems_list:
print(item)
Afterimages:Audre Lorde:1997
The Shadow:William Carlos Williams:1915
So, if i use .append oll is good:
highlighted_poems_list = ['Afterimages:Audre Lorde:1997', ' The Shadow:William Carlos Williams:1915']
highlighted_poems_stripped = []
for i in highlighted_poems_list:
highlighted_poems_stripped.append(i.strip())
print(highlighted_poems_stripped)
[‘Afterimages:Audre Lorde:1997’, ‘The Shadow:William Carlos Williams:1915’]
Why in for loop we must use .append?