Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS Swift Basics (retired) Control Flow For-In Loop

Adam Blomberg
Adam Blomberg
700 Points

for-in loop, swift. I don't really know how to pass this challenge.

Hi, i'm not really that kind of person who can solve so many things on my own so i don't actually know how to solve this challenge for my own. This was what i thought suit best.

for_loops.swift
for number in 1...10 {
print("\(number) \(number*7")
}

1 Answer

Kourosh Raeen
Kourosh Raeen
23,732 Points

First of all, you are missing a close parenthesis around number*7. Then use println instead of print so that each line is on a new line. Finally, make sure you are printing each line exactly as requested. Right now * 7 = is missing from your output. Here's the code:

for number in 1...10 {
  println("\(number) * 7 = \(number*7)")
}
Adam Blomberg
Adam Blomberg
700 Points

Thank you, i wrote this fast just to have something to show you. Anyway i always forget to write 'println' because in Swift 2.0 you don't need it.