Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS Swift Collections and Control Flow Control Flow With Conditional Statements Working With Switch Statements

please, what am I doing wrong? need help as quick as possible! Tnx

I don't know what I am doing wrong. I can't think of anything that I am doing wrong. Help me, please.

let world = [
    "BEL": "Brussels",
    "LIE": "Vaduz",
    "BGR": "Sofia",
    "USA": "Washington D.C.",
    "MEX": "Mexico City",
    "BRA": "Brasilia",
    "IND": "New Delhi",
    "VNM": "Hanoi"]

for n in world {
    // Enter your code below
switch world {
case "BEL", "BGR", "LIE": europeanCapitals.append(n)
case "IND", "VNH": asianCapitals.append(n)
default: otherCapitals.append(n)
    // End code

1 Answer

Greg Kaleka
Greg Kaleka
39,019 Points

Hi there,

It looks like you've changed the for loop from what was already in the challenge code. You want to leave this line intact:

for (key, value) in world {

The dictionary is made up of keys and values, so we have to address both. For example, the first item in the array has "BEL" as the key and "Belgium" as the value. The challenge is asking you to populate the arrays with just the country names (which are the values in the dictionary). So what you want to do is switch on the key from each item in the dictionary, and if it matches the right region, append the value to that region's array.

Give it another try and report back :blush:.

Cheers :beers: