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 trialVarun Kashyap Kuturu
17,963 PointsThe website shows that there is an error in this program
Anything wrong in this program? Xcode shows the result correctly, but the website did not accept my program. I am sharing my program with you all. Can anyone please help me out.
var results: [Int] = []
for n in 1...100 { // Enter your code below if !(n % 2 == 0) && (n % 7 == 0){ print(n) } }
results += [7,21,35,49,63,77,91]
1 Answer
Jennifer Nordell
Treehouse TeacherHi there! While the resulting array would be correct, the way you're doing it does not meet the challenge specifications. In your loop you're printing the value of n. However, the challenge explicitly states that the number should be appended to the array inside the loop if it meets the specifications (odd and evenly divisible by 7). No printing is required for this challenge. Try this again by using the append()
method to append the number to the existing empty array. Good luck!
Varun Kashyap Kuturu
17,963 PointsVarun Kashyap Kuturu
17,963 PointsI cannot perform this operation using append() as there are many numbers and moreover the code challenge says that (odd numbers and multiple of 7). So the values which I got are [7,21,49,63,77,91].
Varun Kashyap Kuturu
17,963 PointsVarun Kashyap Kuturu
17,963 Pointswithout using the print(n) operation, I cannot get the values for (odd and multiples of 7). If possible can you please share your program.
Thank you
Jennifer Nordell
Treehouse TeacherJennifer Nordell
Treehouse TeacherHi again! I'm not sure why you're unable to use the append as described, so I'll show my code. I would advise reviewing any videos covering anything you do not understand in this code.
Happy coding!
Varun Kashyap Kuturu
17,963 PointsVarun Kashyap Kuturu
17,963 PointsHey Jennifer! are you done with soccer team coordination project? If yes, can you please share your program with me Thank you.
Jennifer Nordell
Treehouse TeacherJennifer Nordell
Treehouse TeacherKarthik Mada No. I've never done the soccer project as I'm neither a Techdegree student nor graduate.
That being said, receiving code for a project used for the Techdegree and using it might violate Treehouse's TOS in regards to academic dishonesty.
You can view the Techdegree Program's Code of Conduct under section 10 at this link.
Good luck!