Python Introducing Lists Using Lists Continental

Luis Martinez
Luis Martinez
5,986 Points

I can't figure out the second task can anyone help?

I've tried just about everything I came across the web and nothing works! Please help

1 Answer

cs16
cs16
Python Web Development Techdegree Student 24,359 Points

Hola Luis,

You need to iterate through the list with a LOOP, fun.

for _ in continents:
    print('* {}'.format(_))

For the second step, well hmmm, yas, theres two ways I can think of you can do this!

You could ... say... use indexes.

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

BTW the previous snippet is the same as this:

for _ in continents:
    if _[0] == 'A': print( '* %s' % (_))

Keep in mind that str has methods, so, you can ALSO use the str.startswith() function like this!!

for _ in continents:
    if _.startswith('A'):
        print('* {}'.format(_))
    else:
        continue

Happy bug hunting!