Python Introducing Lists Using Lists Continental

Caleb Newell
Caleb Newell
3,590 Points


every time i load this code it replies: TabError: inconsitant use of tabs and spaces. A little help here please.
continents = [
    'South America',
    'North America',
# Your code here
for continent in continents:
    print("* " + continent)
    if(continent[0] == "A"):
        print (continent)

2 Answers

Mustafa Başaran
Mustafa Başaran
28,018 Points

Hi Caleb,

You only need 3 lines of code in the second step: Loop through each element of the list. If the first character of the element is A, then print that element out in the special format.

Below code snippet exactly does this.

for c in continents:
    if c[0] == 'A':
        print("* {}".format(c))

(In the loop you have typed above, you are actually printing everything twice.)

I hope this helps.

Caleb Newell
Caleb Newell
3,590 Points

Thanks for the help every one! Much Thanks :)