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 trial

iOS Swift Collections and Control Flow Control Flow With Loops For In Loops

Raymond Choy
seal-mask
.a{fill-rule:evenodd;}techdegree seal-36
Raymond Choy
iOS Development with Swift Techdegree Graduate 11,187 Points

I can't understand what is being asked for the second part of this challenge.

I can't understand what is being asked for the second part of this challenge. I need help

loops.swift
// Enter your code below
for multiplier in 1...10 {
    print("\(multiplier) times 6 is equal to \(multiplier * 6)")
}
var results = ["1 times 6 is equal to 6",
"2 times 6 is equal to 12",
"3 times 6 is equal to 18",
"4 times 6 is equal to 24",
"5 times 6 is equal to 30",
"6 times 6 is equal to 36",
"7 times 6 is equal to 42",
"8 times 6 is equal to 48",
"9 times 6 is equal to 54",
"10 times 6 is equal to 60"]
Aaron Hartley
Aaron Hartley
1,525 Points

I agree that I have the first part but the append is giving me fits. Does it actually go into the for in loop or outside?

2 Answers

Magnus Hållberg
Magnus Hållberg
17,232 Points

In the second step you are suppsed to append the value calulated from "multiplier" times 6. Like you have done in your print method only using the append method on the results array instead. And of cores only the calculation and not the other text since that results array expects an Int value.

// Enter your code below
var results: [Int] = []
for multiplier in 1...10 {
  results.append(multiplier * 6)
}
Aaron Hartley
Aaron Hartley
1,525 Points

When trying this code it just gives an error

Aaron Hartley
Aaron Hartley
1,525 Points

I got the system to accept my answer by inserting the first 10 multiples of 6 in the array but I didn't even use the append method. I would still like to know how it should be done.

Magnus Hållberg
Magnus Hållberg
17,232 Points

Please include your code. What was the error you got when using the code from my answer?