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 trialArthur Boilanger
3,372 PointsUnable to Append multiplier to results array
I'm having an issue with appending the value that my for-in loop "multiplier"
for multiplier in 1...10 {
print("\(multiplier) times 6 is \((multiplier) * 6)")
}
to my results array for the 2nd challenge task.
I've tried using
results.append(multiplier)
but keep coming up with an error.
1 Answer
Steve Hunter
57,712 PointsHi Arthur,
You want to append results.append(multiplier * 6)
as the array should hold, to quote the question, the array will contain the first 10 multiples of 6
I hope that helps.
Steve.
Arthur Boilanger
3,372 PointsArthur Boilanger
3,372 PointsHi Steve,
I tried that and am now getting an error saying
Thanks for taking the time to help, I appreciate it!
Steve Hunter
57,712 PointsSteve Hunter
57,712 PointsJust checking that you've got that line in the right place. It needs to go inside the
for
loop:THe name of the variable in the for loop needs to match the variable being multiplied and appended. The challenge wants that to be called
multiplier
. That code clears the challenge.Steve.
Arthur Boilanger
3,372 PointsArthur Boilanger
3,372 PointsD'oh! I figured it out!
I was putting results.append outside of the loop, so it didn't know what multiplier was.
It should read as follows:
Steve Hunter
57,712 PointsSteve Hunter
57,712 PointsSpot on! Good work. :-)