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

Kavita Bargota
Kavita Bargota
2,741 Points

can anyone help with this please?

I am not sure what i am doing wrong here??

loops.swift
// Enter your code below
for multiplier in 1...10 {
print ("\(multiplier) times 6 is equal to \(multiplier * 6)")
}

1 Answer

Andrew .
Andrew .
1,830 Points

Hey I am too a beginner and saw your questions a few hours before I got onto the loops part of the course. I literally just finished that question and it was the most time consuming one yet! It took me 15 minutes to solve so don't worry if you're struggling on this questions I'd assume everyone does. Onto the solution, the questions asks for you to just show integers that are 1-10 * 6. your most noticeable problem is putting a string in the print code. All it asks for is: print("(multiplier * 6)") that just gives the answer as an integer.

Also, you forgot the rest of the code to put the new multiples into the array named results.

Here is the full code you would need, but it's best you fully understand the concepts as it took me 15-20 minutes but is much more clear now!

var results: [Int] = [] for multiplier in 1...10 { print("(multiplier * 6)") results.append(multiplier * 6) }

Kavita Bargota
Kavita Bargota
2,741 Points

Hi Andrew!

thank you so much for your help :)

it makes sense not but i think you are correct in saying I need to understand it fully.

I hope you are making good progress with this track :)

Kavita