Fundamentals6 / 8
Up next

for and while

// half-open range 1..<4 yields 1, 2, 3
var total = 0
for i in 1..<4 {
    total += i
}
print(total)
// while repeats until the condition is false
var k = 3
while k > 0 {
    k -= 1
}
print(k)
What you're solving

for-in over a range, while loop