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 trialTim Seme
1,664 Pointscan someone tell me whats wrong y is it not letting me through
for multiplier in 1...10 { print("(multiplier) times 6 equal to (multiplier * 6)") var results: [Int] = [6] results.append(multiplier) }
// Enter your code below
for multiplier in 1...10
{ print("\(multiplier) times 6 equal to \(multiplier * 6)")
var results: [Int] = [6]
results.append(multiplier)
}
2 Answers
David Papandrew
8,386 PointsYou've got the initial part of the for loop setup right. It's just the code to be executed inside the loop that is wrong.
The gist of it is that with each loop, you will append a value from that iteration to the results array. The value to returned is 6 times the value of the multiplier. On the first loop, the multiplier is 1. Second loop it is 2, etc, etc.
Here is the code:
// Enter your code below
var results: [Int] = []
for multiplier in 1...10 {
results.append(multiplier * 6)
}
Tim Seme
1,664 PointsI tryed this it told me that the append isn't compatible with integers
David Papandrew
8,386 PointsDavid Papandrew
8,386 PointsWhat is the exact code you are trying to pass with? I just tried the code I supplied and passed, no problem.
Tim Seme
1,664 PointsTim Seme
1,664 Pointsok so i did this and it still wont let me through because i have to add "mex" and "usa" but they dont go to asian or eurpeanCapitals so where do i add these
var europeanCapitals: [String] = [] var asianCapitals: [String] = [] var otherCapitals: [String] = []
let world = [ "BEL": "Brussels",// eur "LIE": "Vaduz",// eur "BGR": "Sofia",// eur "USA": "Washington D.C.", "MEX": "Mexico City", "BRA": "Brasilia",// eur "IND": "New Delhi",// eur "VNM": "Hanoi"]//asian
// Enter your code below for (key, value) in world { switch(key) { case "BEL", "LIE", "BGR", "BRA", "IND":europeanCapitals.append(value) case "VNM":asianCapitals.append(value) default: otherCapitals.append(value) }
}