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

Not sure why I'm getting an Assertion Error

My output is correct or at least it looks correct to me, but after the second time it was run, I'm getting a 'Assertion Error.'

continents.py
continents = [
    'Asia',
    'South America',
    'North America',
    'Africa',
    'Europe',
    'Antarctica',
    'Australia',
]
# Your code here
for continent in [0, 1, 2, 3, 4, 5, 6]:
    print("* ", continents[continent])

5 Answers

Chris Freeman
MOD
Chris Freeman
Treehouse Moderator 68,441 Points

It's not obvious from the output, but comma-separated arguments to print() are output with a space between then. Since the first item includes a space in "* ", then effectively there are two spaces.

So I assume you just delete the white space and all is good?

Chris Freeman
Chris Freeman
Treehouse Moderator 68,441 Points

Correct. You can:

  • remove the white space
  • add the sep='', argument to print()
  • use a formatted string such as:
    • f"* {continent}"
    • "* {}.format(continent)"`
    • "* %s" % continent

My apologies, Chris! I must have clicked it by accident.

u"\U0001F44D"

Chris Freeman
Chris Freeman
Treehouse Moderator 68,441 Points

Treehouse allows markup for "thumbs up". Using ":thumbsup:" or ":+1:" ==> :thumbsup:

Manuel Canario
Manuel Canario
1,458 Points

I am really lost, this is the way I did it, however, I have not found any instructions on the "f" function uses.

continents = [
    'Asia',
    'South America',
    'North America',
    'Africa',
    'Europe',
    'Antarctica',
    'Australia',
]
# Your code here

for continent in continents:
    if  continent(0) == 'A':
    print("* "+ continent)
Chris Freeman
Chris Freeman
Treehouse Moderator 68,441 Points

Very close. continent isn’t a function which is what the parens imply. Use continent[0] instead.