5️⃣

6.5 Iterating Through a List

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

Next Section

⚖️

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 classes@code4tomorrow.org for inquiries.