Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Darrin Spell Jr
Full Stack JavaScript Techdegree Student 10,303 PointsI don't quite understand what I am doing wrong.
I watched the video 5 times and I feel like I am missing something with this code challenge.
continents = ['Asia', 'South America', 'North America', 'Africa', 'Europe', 'Antarctica', 'Australia']
for continent in continents:
print("* " + continents)
3 Answers

Jerson Otzoy
1,532 PointsHope this helps
numbers = [1, 3, 5]
Say that we want to square each of the numbers in this list
for number in numbers:
print(number * number)
If you run this the result would be this
1
9
25
What happened here step by step is:
- We set a list (
numbers
) with five elements. - The program takes the first element from the list and store it in a variable called
number
. - The result of the operation
number * number
is printed. (In this case for the first element 1, the result is 1) - Then the program does this same operation for the remaining elements in the list.
Basically we are telling the program to do something with each element in the list, and we are referring to that element by the name number
.

Jerson Otzoy
1,532 PointsHello, since you are iterating in the list you should use the element variable name instead of the list name inside the for loop:
print("* " + continent)

Darrin Spell Jr
Full Stack JavaScript Techdegree Student 10,303 PointsCan you explain in a bit more detail please. I don't get this for and in concept of for and in
Darrin Spell Jr
Full Stack JavaScript Techdegree Student 10,303 PointsDarrin Spell Jr
Full Stack JavaScript Techdegree Student 10,303 PointsOhhh I think I get it now. so we use for to create a new variable to modify whatever element we want in the list and you can also specify parts of the list with indexing. Does that sound about right or am I off a bit?
Jerson Otzoy
1,532 PointsJerson Otzoy
1,532 PointsYes, that sounds about right.