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

Steve Pham
Steve Pham
1,488 Points

i need help this challenge



1 Answer

Chris Shaw
Chris Shaw
26,676 Points

Hi Steve,

For this challenge we need to use the range operator, the rest of the code has already been covered already in previous videos/challenges so it at all it doesn't make sense I recommend you go back and watch/re-do them.

for num in 1...10 {
  println("\(num) * 7 = \(num * 7)")

So what's happening here is we declare num as the value assignment for the loop, next we declare our range operator which we start at 1 since times tables start at 1 and end it at 10 as specified by the challenge, what this tells our for loop to do is count from 1 to 10 but not anymore than 10 which will result in 10*7 been the final result we get.

See the below link for more information about operators in Swift.

Basic Operators - Swift

Happy coding!