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

cannot assign to value: binary operator returns immutable value.

for n in 1...100 { if 0 != (n % 2) && 0 = (n % 7) { print(n) } } this is what i was experimenting with in my playground to figure out why I couldn't pass the code challenge. it kept telling me I didn't have a conditional statement. now in the playground I get the message above.

3 Answers

Try to put n % 7 == 0 and then && n % 2 != 0, probably treehouse is looking for that specific order.

it was the == on n % 7 == 0, I had a single =.

In if statements you would put the question first, for example instead of 0 != (n % 2), you would write n % 2 != 0, and also the challenge is asking you to append n, so instead of print() you are going to append n to results by writing results.append() and the scoped variable n goes inside the brackets.

yeah that's what i tried first and it gave me the same problem.

Man, sometimes is just a little bit hard to spot does small syntax errors, I'm glad I could help.