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 trialTerrell Winston
Courses Plus Student 1,811 Pointsto do this you're going to use a switch statement
nooo clue how this code works need major help can't tell if im ont he right path or not i get lost within the body of the switch staement
var europeanCapitals: [String] = ["Brussels", "Sofia","Vaduz" ]
var asianCapitals: [String] = []
var otherCapitals: [String] = []
let world = [
"BEL": "Brussels",
"LIE": "Vaduz",
"BGR": "Sofia",
"USA": "Washington D.C.",
"MEX": "Mexico City",
"BRA": "Brasilia",
"IND": "New Delhi",
"VNM": "Hanoi"]
for (key, value) in world {
// Enter your code below
switch world{
case "BEL": print("Brussels")
case "LIE": print("Vaduz")
case "BGR": print("Sofia")
case "USA": print("Washington D.C.")
case "MEX": print("Mexico City")
case "BRA": print("Brasilia")
case "IND": print("New Delhi")
case "VNM": print("Hanoi")
}
europeanCapitals.append ("Brussels", "Sofia","Vaduz" )
asianCapitals.append ("New Dehli", "Hanoi")
otherCapitals.append ("Washington D.C.","Brasilia","Mexico City")
// End code
}
1 Answer
Jhoan Arango
14,575 PointsHello :
I will guide you a bit through the code so you can understand it a bit. But will not give you the complete answer so that you can solve it yourself. This way, it helps you a bit more and not just get the answer.
The challenge is asking you to Switch on the key value. You are switching in world. Also the switch should look something like this.
switch key {
case key "USA":
array.append(value)
default: break
}
Good luck, if you need more help let me know.
Terrell Winston
Courses Plus Student 1,811 PointsTerrell Winston
Courses Plus Student 1,811 Pointsthank i figured it out after slowing down and understanding the question.