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

for in loops 2

I've just had a another go although this looks better its still incorrect what am i doing wrong ?

Thanks

Alia :)

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

1 Answer

Logan R
Logan R
22,989 Points

You're very close! You need to slightly change your print statement.

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

Thank you :)

Logan R
Logan R
22,989 Points

No problem :) The syntax is slightly weird to be honest. If you have any other questions or need some clarification, feel free to ask!

Thank you why do i need an \ before (number)

Logan R
Logan R
22,989 Points

In general, a \ means to do something adnormal with the character that is coming next. For instance, in Java, if you do print("Have a great day!\n"); the \n means to add a new line.

In the case of Swift, \( means to read until the ) and pre-process the information before printing it.

Does that make sense?