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 trialpogtynmsax
4,083 PointsIf statement for n is both odd and multiple of 7 in a range of 1...100. Then append value to an array named results.
Challenge is asking to write an If statement for n is both odd and a multiple of 7 in a range of 1...100. Then append value to an array named results...
var results: [Int] = []
for n in 1...100 {
// Enter your code below
// if the remainder of n times 2 is not equal to 0 (not clean and n is not even)
// and
// if the remainder of n times 7 is equal to 0 (clean and n is multiple of 7)
If n % 2 != 0 && n % 7 == 0 {
// append it to the results array
results.append(n)
}
// End code
}
1 Answer
Chris Stromberg
Courses Plus Student 13,389 PointsCheck your capitalization on your if statement!
it's if not If
pogtynmsax
4,083 Pointspogtynmsax
4,083 PointsWow! I overlooked that. Thanks Chris.