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 trialAndrew Chung
5,203 PointsCode not working
for i in 1...20 {
if (i % 3 == 0) && (i % 5 ==0) {
println("Fizzbuzz")
} else if (i % 3 == 0) {
println("Fizz")
} else if (i % 5 == 0) {
println("Buzz")
} else {
println(i)
}
}
From what I can tell my code is identical to the one in the video but xcode is saying that I need a comma after the 5 in the second line.
Andrew Chung
5,203 PointsThanks Kyle! I didn't think the spacing mattered but I guess it does in Swift.
1 Answer
Tingting Gu
10,760 PointsKyle's answer works. You can also do it in conditions without parentheses.
kjvswift93
13,515 Pointskjvswift93
13,515 PointsYou need to simply add a space between the == and 0 in your second line.