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

Edwin Mhoy Silva Rifa
Edwin Mhoy Silva Rifa
2,631 Points

Having a hard time making a times table

I canΒ΄t seem to get i right

I wrote my gode like this for number in 1...10 { println ("\number*7")}

1 Answer

The way I made a times table would be:

for number in 1...10 {
    println("\(number) times 2 is \(number*2)")
}

I then get this output in the console

1 times 2 is 2

2 times 2 is 4

3 times 2 is 6

4 times 2 is 8

5 times 2 is 10

6 times 2 is 12

7 times 2 is 14

8 times 2 is 16

9 times 2 is 18

10 times 2 is 20

Same rules apply for 7 times table...

for number in 1...10 {
    println("\(number) times 7 is \(number*7))
}