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 Collections and Control Flow Control Flow With Conditional Statements Working With Logical Operators

Richard Pitts
PLUS
Richard Pitts
Courses Plus Student 1,243 Points

Not sure here either...

Not sure here either...

operators.swift
var results: [Int] = []

for n in 1...100 {
    // Enter your code below
    if n % 2 = 0 && n %7 != 0 {
    return results.append 
    }
    // End code 
}

2 Answers

Nichlas Kondrup
Nichlas Kondrup
17,748 Points

You're very close. You should use the not equal operator at the first statement instead of the last and remember that the equal operator is written with two equal signs otherwise you assign a value.

var results: [Int] = []

for n in 1...100 {
    // Enter your code below
    if (n % 2 != 0) && (n % 7 == 0) {
       results.append(n)
    }
    // End code 
}
Jason Anders
MOD
Jason Anders
Treehouse Moderator 145,860 Points

Hi Richard,

I've noticed numerous posts made by you in the past hour. While the community is a place to go for help, before multiple postings, you should try one or more of the following to troubleshoot and debug yourself:

  1. Reviewing the applicable material again. Sometimes watching the video again (even a 3rd time) will help the material make more sense and aide in completing the challenges.
  2. Give the challenges a try and then debug using the error messages provided by the code checker.
  3. Search the Community for related posts for the trouble you are having.
  4. Use your preferred search engine to 'look-up' the errors you are receiving in your code. Odds are someone at some point encountered the same issue. (This will be a very useful tool in debugging any code).

If all else fails, feel free to then post the question to the community. Remember, just asking questions and receiving answers is not the best way to learn code.

Keep Coding! :) :dizzy:

Richard Pitts
Richard Pitts
Courses Plus Student 1,243 Points

Okay sorry, I was worried about overloading you all. I had saved up all of the challenges to do all at once. It won't happen again and I will take your advice.