Welcome to the Treehouse Community
The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Gabriel Franco
656 Pointshonestly I'm idk where to start
need help
var results: [Int] = []
for n in 1...100 {
if n is odd { print ( "okay")
}
// End code
}
2 Answers

Steven Deutsch
21,046 PointsHey Gabriel Franco,
You have the right idea. The challenge is asking you to check the number for two conditions. If it evaluates to true for both conditions, we will append it to the results array.
The first condition we need to check for is if the number is odd. We can do this by using the remainder operator and 2. If we divide the number by 2 and get a remainder of 0, the number will be even because it divided equally. So in order for the condition to be true for the case of an odd number it looks like this: n % 2 != 0
The next condition we need to check for is if the number is a multiple of 7. We can use the remainder operator and 7 here. If the number divides by 7 with no remainder (zero) then the number must be a multiple of 7.
We want to use the AND operator (&&) to check if both of these conditions are true before we append the number to the results array.
var results: [Int] = []
for n in 1...100 {
if n % 2 != 0 && n % 7 == 0 {
results.append(n)
}
// End code
}
Good Luck!

Gabriel Franco
656 Pointsthanks a lot makes a lot of sense now