So for example
cast = ["Barney Stinson", "Robin Scherbatsky", "Ted Mosby", "Lily Aldrin", "Marshall Eriksen"]
heights = [72, 68, 72, 66, 76]
//loop
for i, name in enumerate(cast):
cast[i] = name + " " + str(heights[i])
print(cast)
If I indent the code to include it in the for loop, the print statement will return multiple copies of my output, and in a completely chaotic order. However when I instead use the print statement without an indent, everything works out fine as I return names and heights in order. Obviously the loop is the problem, but it's not the first time I've encountered this, and i'd appreciate a full in-depth explanation. Thnx!
print(cast[i])