treehouse, quiz, list iteration

IB Year 1 HL Computer Science
Forum rules
Please be careful about sharing personal information. Never use any identifiable information.
Post Reply
User avatar
minseok123
Helper!
Posts: 9
Joined: 17 Sep 2018, 10:14

treehouse, quiz, list iteration

Post by minseok123 » 08 Oct 2018, 12:47

https://teamtreehouse.com/library/intro ... ontinental

MY CODE

continents = [
'Asia',
'South America',
'North America',
'Africa',
'Europe',
'Antarctica',
'Australia',
]
# Your code here
for continent in continents:
print("* " + continent)

II dont know how to move on from here to only print continents that begin with the letter "A"
1 x

User avatar
Mr. MacKenty
Site Admin
Posts: 88
Joined: 28 Apr 2018, 17:06
Answers: 3

Re: treehouse, quiz, list iteration

Post by Mr. MacKenty » 08 Oct 2018, 21:39

Hiya Minseok.

1. Please use the code formatting button next time you paste code here, it makes it easier to see. Please let me know if you need a reminder to use it.

What if you tried something like this:

Code: Select all

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

# Your code here
for continent in continents:
	if continent[0] == "A":
 		print("* " + continent)

Could you please tell me if this works?

minseok123 wrote:
08 Oct 2018, 12:47
https://teamtreehouse.com/library/intro ... ontinental

MY CODE

continents = [
'Asia',
'South America',
'North America',
'Africa',
'Europe',
'Antarctica',
'Australia',
]
# Your code here
for continent in continents:
print("* " + continent)

II dont know how to move on from here to only print continents that begin with the letter "A"
0 x

User avatar
minseok123
Helper!
Posts: 9
Joined: 17 Sep 2018, 10:14

Re: treehouse, quiz, list iteration

Post by minseok123 » 09 Oct 2018, 23:29

It works, thank u :)
1 x

Post Reply