Iterating Through a List

You can iterate through each element in a list using a for loop. For example:

# for each item in my_list
for item in my_list:
	# print that item
	print(item)

View code on GitHub.

The code above prints each element in my_list on its own line

Previous Section

6.4 Manipulating Lists

Next Section

6.6 Membership Operators

<aside> ⚖️ Copyright © 2021 Code 4 Tomorrow. All rights reserved. The code in this course is licensed under the MIT License.

If you would like to use content from any of our courses, you must obtain our explicit written permission and provide credit. Please contact [email protected] for inquiries.

</aside>