Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialMarcio Mello
7,861 PointsSyntax confusion (EACH / FOR)
In this video, the instructor first start with:
each key in list
Thank copy and paste a more robust code with:
for key in list
In the quiz at the end of this lesson there is a question that put both syntax as possible answers.
I chose EACH and it was correct. But what about FOR? It worked in his example.
1 Answer
Talmage Shill
Courses Plus Student 7,593 PointsBoth FOR and EACH are valid. I took the quiz twice and the first time I chose EACH, like you, and got it right. The second time, I chose FOR and also got it right. I don't know why there are two keywords for the same operation, but they are both syntacticly valid.
I hope this helps. Let me know if there is anything else I can do.