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 trialRandell Purington
9,992 PointsWhere am I getting my error from?
swift_lint.swift:10:10: error: expected '{' after 'if' condition if n 2 % 1 == && n % 7 == 0 { ^ swift_lint.swift:10:33: error: braced block of statements is an unused closure if n 2 % 1 == && n % 7 == 0 { ^ swift_lint.swift:10:8: error: 'Int' is not convertible to 'Bool' if n 2 % 1 == && n % 7 == 0 { ^ swift_lint.swift:10:33: error: expression resolves to an unused function if n 2 % 1 == && n % 7 == 0 {
var results: [Int] = []
for n in 1...100 {
// Enter your code below
if n 2 % 1 == && n % 7 == 0 {
results.append(n)
}
// End code
}
1 Answer
miikis
44,957 PointsHey Randell,
To check if an integer is even or odd, you’ll want to see if said integer is evenly divisible by two. So, if an integer is divided by two and leaves no remainder, then that integer is even.
The Challenge, though, wants to know which integers are odd. So, instead of if n % 2 == 0
, you’d filter for the opposite: if n % 2 != 0
.
Finally, don’t forget that the Challenge doesn’t just want odd numbers; it wants numbers that are cleanly divisible by 7.
You should probably be able to figure it out from here. Feel free to ask for clarification if you need it ;)