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 trialKen Gerlinger
2,898 PointsHow can I append the results of a loop into a var ?
In can't find a way to store the data of the loop "multiplier" in the var "results". Please help me.
// Enter your code below
var results: [Int] = []
for multiplier in 1...10 { print("\(multiplier * 6)")}
results.append("\(multiplier)")
2 Answers
Ken Gerlinger
2,898 PointsThank you !
Mathieu St-Vincent
9,244 PointsYou need to insert the results.append inside the loop, and include only the value of the variable instead of the string value.
Also, the challenge does not require you to print anything.
var results: [Int] = []
for multiplier in 1...10 {
results.append(multiplier * 6)
}
Mathieu St-Vincent
9,244 PointsMathieu St-Vincent
9,244 PointsYou're welcome. If the answer did satisfy you, please mark it as answered :)