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 trialmauricio almonte
1,913 Pointsi 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 = [
'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
231,275 PointsIn 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
1,913 Pointsmauricio almonte
1,913 Pointsi need a break, that was TOO OBVIOUS. i just changed it to .upper, THANKS!!!!! .
Steven Parker
231,275 PointsSteven Parker
231,275 PointsYou don't need "upper", since "A" is already upper case.