Dear StackOverFlow, I just starting learning python, and I'm a little confused when it comes to looping through lists. I have been using Python.org's official python tutorial to learn. In section 4.2 on this page https://docs.python.org/2/tutorial/controlflow.html, in the last example they write this code:
for w in words[:]:
if len(w) > 6:
words.insert(0, w)
The part that confuses me is for w in words[:]:
Maybe I need to read their description a little better, but I can't seem to figure out why
the previous code works and this doesn't:for w in words:
. I guess it confuses me because when i type words[:] in the interpreter I get the same result when i type words in the interpreter. If you could shed some light on this topic, I would be very grateful.