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 trialmaksymilianuszycki
1,143 PointsStuck on loops challenge
Everything i try turns out to be wrong and i can't think of anything else.
The one error that shows up is "swift_lint.swift:5:1: error: expected expression in container literal for multiplier in 1...10 {print("(multiplier) times 6 is equal to (multiplier*6)"}"
Can anyone tell me what's wrong here?
maksymilianuszycki
1,143 Pointsvar results: (Int) = [ for multiplier in 1...10 {print("(multiplier) times 6 equals to (multiplier*6)")]
1 Answer
swiftfun
4,039 PointsHi Maksymilian,
For this challenge you are only required to append the results of each multiplication into the results array.
You are not required to PRINT the full table as you were trying to do.
What you need to do is the following.
First you create the for-in loop, and iterate over the 1...10 range (just like you did)
Then since you are ONLY required to append the results, you only create an append function, multiplying each "multiplier" times 6.
for multiplier in 1...10 {
results.append(multiplier * 6)
}
As well I would advise you to correct your syntax for String Interpolation:
The syntax is /(valueGoesHere)
maksymilianuszycki
1,143 PointsThanks a lot mfagency!
Brendan Whiting
Front End Web Development Techdegree Graduate 84,738 PointsBrendan Whiting
Front End Web Development Techdegree Graduate 84,738 PointsCan you post the code that resulted in that error message?