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 trialAlia Khan
3,733 Pointsfor 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 numbers in 1...10{
println("numbers)\(number * 7)")
}
1 Answer
Logan R
22,989 PointsYou're very close! You need to slightly change your print statement.
for number in 1...10 {
println("\(number) * 7 = \(number * 7)")
}
Alia Khan
3,733 PointsAlia Khan
3,733 PointsThank you :)
Logan R
22,989 PointsLogan R
22,989 PointsNo problem :) The syntax is slightly weird to be honest. If you have any other questions or need some clarification, feel free to ask!
Alia Khan
3,733 PointsAlia Khan
3,733 PointsThank you why do i need an \ before (number)
Logan R
22,989 PointsLogan R
22,989 PointsIn general, a
\
means to do something adnormal with the character that is coming next. For instance, in Java, if you doprint("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?