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 trialJake N
612 Pointsin the video your not explaining how {} work...
all of a sudden it skips down lines and print pops up. hows that happen, i type it into the answer on the challenge (replacing the 2s with 7s) and it doesn't work
for number in 1...10 {
5 Answers
Stone Preston
42,016 Pointsthe task states Use a for-in loop to print out a "7 times table". Your output should look like this:
1 * 7 = 7
2 * 7 = 14
Etc., all the way up to 10. Each line should be on a new line.
we can use a range and a for loop to loop through all the numbers 1 through 10.
we can then use string interpolation to interpolate the number variable, and the number variable * 7 to create the desired output
for number in 1...10 {
println("\(number) * 7 = \(number * 7)")
}
Stone Preston
42,016 Pointsyou use { } to create code blocks, or pieces of code that are grouped together. blocks of code like this are common when using loops, functions, etc
at 4:39 of this video amit opens a new block of code ( {} ) after the for in loop.
he then manually types print and selects println from autocomplete. it does not just pop up. the code challenge engine is not xcode, so it does not support code completion. you will have to type all code out yourself
Jake N
612 Pointsno, what I'm saying is it randomly goes from this line {
to down here } and he doesn't explain how you do that
Stone Preston
42,016 Pointsoh, you press enter/return.
for number in 1...10 { //then press return a few times to create new lines
} // then add the brace
is that what you mean?
Jake N
612 Pointsi still can't figure out what the answer is, i feel like i am typing it in right but its still saying wrong, the error doesn't explain whats wrong about it
Jake N
612 Pointsah okay thanks, i think i was leaving out the second \