Python Introducing Lists Using Lists Continental

mauricio almonte
mauricio almonte
1,706 Points

i dont understand this

why this works?

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

for a in continents: print("*",a)

for a in continents: if a[0] == "A" print(a)

and this does not:

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

for a in continents: print("*",a)

for a in continents: if a[0] == "A".lower():
print(a)

i am referring to the second FOR LOOP, .lower does not seem to take effect, probably i am missing something, HELP

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

for a in continents:
    print("*",a)


for a in continents:
      if a[0] == "a".lower():
            print(a)

1 Answer

Steven Parker
Steven Parker
171,373 Points

In the second one, you're trying to match with "A".lower(), which is the same thing as "a" (lower-case "a"). And none of the names start with "a" (but several start with "A").

mauricio almonte
mauricio almonte
1,706 Points

i need a break, that was TOO OBVIOUS. i just changed it to .upper, THANKS!!!!! .

Steven Parker
Steven Parker
171,373 Points

You don't need "upper", since "A" is already upper case.