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

Why isn't this code working?

Hello, I and doing a code challenge and I don't exactly know what to do. If someone could please explain to me what is happening that would be great.

loops.swift
// Enter your code below
var results: [Int] = []

for multiplier in 1...10{
  print("\(multiplier) times is 6 is \(multiplier * 6)")
}

2 Answers

Jeff McDivitt
Jeff McDivitt
23,970 Points

Hi Brendan -

You do not need to print anything, the challenge is asking you to append

var results: [Int] = []

for multiplier in 1...10 {

results.append (multiplier * 6)

}

Thanks! ?

Could someone briefly explain to me what that means?

Jeff McDivitt
Jeff McDivitt
23,970 Points

In the for loop 1...10 you are taking the value and multiplying it by default 6 for each value in 1 through 10 you are using the append method to append the multiplier * 6