I started learning Python recently and while using lists I faced this problem.
Here I assigned some movie names to variable movies
:
>>> movies = ["dragon","dragon warrior","kungfu","kungfu panda"]
after assigning, I used the print
command to execute it:
>>> print(movies)
the output is as below:
['dragon', 'dragon warrior', 'kungfu', 'kungfu panda']
In the same way, when I started using a for-loop in lists with the same print
command, the output is entirely different. I can't understand how it changed because of the for-loop:
>>> for fav_movie in movies:
print(fav_movie)
output:
dragon
dragon warrior
kungfu
kungfu panda
Why is the same print command working differently?