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 trialNadia Savelyeva
1,644 PointsWhy does player not have to be defined in "for player in players"? [Solved]
Hi,
I'm curious about the "for player in players: " line in this team.py challenge. Player is not defined as a variable, so why does the code work?
Any insight is appreciated. Thank you!
Nadia
1 Answer
Nadia Savelyeva
1,644 PointsThink I just found the answer to my own question in the For Loops video https://teamtreehouse.com/library/for-loops-6
This is due to to the specifics of the For Loops. The variable "player" is automatically defined during the looping process (you can name it whatever as long as that name goes after "for" and precedes "in") and can then be referenced and used in the subsequent function.
Yay!
Chris Freeman
Treehouse Moderator 68,423 PointsChris Freeman
Treehouse Moderator 68,423 PointsNice! Keep up the good work!