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 trialJoakim Weidenius
3,874 PointsWorking with logical operators..
I think i almost have it but it won't get trough when i am checking the work. I can't see whats the problem.
var results: [Int] = []
for n in 1...100 {
// Enter your code below
if n % 7 == 0 && n % 2 !=0 {
results.append[n]
}
}
// End code
1 Answer
andren
28,558 PointsYour code is indeed pretty much correct, the issues are mostly typos. You need to have a space between the != operator and 0 in you if statement, and you use brackets when you call the append method which is wrong, methods are called with parenthesis.
Fixing those two errors like this:
var results: [Int] = []
for n in 1...100 {
// Enter your code below
if n % 7 == 0 && n % 2 != 0 {
results.append(n)
}
}
Will allow you to complete the challenge.