iOS Swift Collections and Control Flow Control Flow With Conditional Statements Working With Logical Operators

Fernando Santos
Fernando Santos
8,424 Points

I can't realize what's wrong

The code seems fine for me but I can't progress.

operators.swift
var results: [Int] = []

for n in 1...100 {
    // Enter your code below
    if n % 7 == 0 && !(n % 2 == 0) {
      results = results + [n]
    }
      // End code 
}

1 Answer

KRIS NIKOLAISEN
PRO
KRIS NIKOLAISEN
Pro Student 45,174 Points

I'm not sure results = results + [n] would append a value to the array. Try this instead:

results.append(n)