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 trial

Python Introducing Lists Using Lists Continental

Kars Jansens
Kars Jansens
5,348 Points

I can't fix this... [Python]

Hey, I got a problem. I realy don't know how to do this. Can some one explain it to me? The question is: Print a bulleted list of each continent from the continents list. Output should look similar to:

continents.py
continents = [
    'Asia',
    'South America',
    'North America',
    'Africa',
    'Europe',
    'Antarctica',
    'Australia',
]
# Your code here
count = 0
for 'Asia' in continents:
    count += 1
    for 'South America' in continents:
        print('')
else:
    del continents[count]
    count += 1
Mohan Kholiya
Mohan Kholiya
1,102 Points

//Q2: Answer

print("continent:")

for continent in continents:

if continent[0] == "A" :

print("* " + continent )

4 Answers

Steven Parker
Steven Parker
229,644 Points

You've got the right idea, but there's a few issues, Here's a few hints:

  • you don't need a "count" for this challenge
  • you only need one loop
  • you don't need an "else" or anything after it (particularly no "del"!)
  • a loop argument must be a variable name instead a constant (like "for item in continents:")
  • the "print" statement must contain what you want to print
  • you can use concatenation (+) to combine a constant string (like "* ") with a variable
Steven Parker
Steven Parker
229,644 Points

It looks like your part 2 solution has an extra loop that is checking every letter of the continent. But the challenge instructions only ask you to check the first letter of the continent.

Also, to make your code readable it needs to be formatted with "Markdown". Use the instructions for code formatting in the Markdown Cheatsheet pop-up below the "Add an Answer" area. :arrow_heading_down:   Or watch this video on code formatting.

Kars Jansens
Kars Jansens
5,348 Points

continents = [ 'Asia', 'South America', 'North America', 'Africa', 'Europe', 'Antarctica', 'Australia', ]

Your code here

for continent in continents: for letter in continent: if letter[0] == "A": print("* " + continent) Hey, I did the first question.. But there is a second question... The problem is that North America and South America are printed... I need to print every continent that's starts with the letter 'A'.

Steven Parker
Steven Parker
229,644 Points

See the comment added to my answer.

Kars Jansens
Kars Jansens
5,348 Points

I still don't see what is wrong...

Kars Jansens
Kars Jansens
5,348 Points

I did it!! It took me 2 hours but I did it. :/ Thank you for helping me.

Steven Parker
Steven Parker
229,644 Points

Kars Jansens — Glad to help. You can mark the question solved by choosing a "best answer".
And happy coding!