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 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,733 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.