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

Nikita Voloboev
Nikita Voloboev
4,816 Points

how come this code does not work for printing the times table?

I just need to print the 7 times table, it prints correctly in xCode. What did I do wrong?

for_loops.swift
for number in 1...7 {
println("\(number) * 7 = \(number * 7)")
}

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

You are doing just fine! You just missed in the instructions where it says it wants you to print the times table up to 10. You have your range set to 7. So it will print out 7, 14, 21, 28, 35, 42, 49 and then stop. It wants you to do the same thing but up to 70. So if you just change your first line... the code passes!

for number in 1...10 {