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 trialDustin Jones
iOS Development Techdegree Student 1,573 PointsEverything looks right, but I can not get a correct answer from this challenge. Please help.
What am I doing wrong and can you please explain?
var results: [Int] = []
for n is 1...100 {
if (n % 2 != 0) && (n % 7 == 0) {
results.append(n)
}
}
4 Answers
Jason Anders
Treehouse Moderator 145,860 PointsHey Dustin,
Your code is correct; however, it looks like you altered a key word in the preloaded code, and that is what is throwing the error.
You changed in
to is
in the opening for loop
. It should read for n in 1...100
. Fix that up and you're good to go.
Keep Coding!
Sean Riley
7,087 PointsYou just have a typo in there, "for n is 1...100" should read "for n in 1...100", the rest of your code is exactly right.
Alexander Davison
65,469 PointsMaybe this will work?
I'm not sure.
var results: [Int] = []
for n is 1...100 {
if (!n) && (n % 7 == 0) {
results.append(n)
}
}
Jason Anders
Treehouse Moderator 145,860 PointsNope, that won't work. Spelling error in for loop
and logic is incorrect in if statement
.
Alexander Davison
65,469 PointsOops, didn't notice that XD