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 Collections and Control Flow Control Flow With Loops For In Loops

Ken Okiebisu
Ken Okiebisu
9,673 Points

Keep getting errors on the Ints and operands

swift_lint.swift:8:52: error: binary operator '*' cannot be applied to operands of type '[Int]' and 'Int' for multiplier in results { results.append(results * 6) } ~~~~~~~ ^ ~ swift_lint.swift:8:52: note: expected an argument list of type '(Int, Int)' for multiplier in results { results.append(results * 6) } ^ I keep getting these errors... can someone please give me a solution to this problem?

loops.swift
// Enter your code below
var results: [Int] = [1,2,3,4,5,6,7,8,9,10]
for multiplier in results { results.append(results * 6) }

2 Answers

Anthony Lafont
Anthony Lafont
17,075 Points

Hi Kenichi,

In this challenge, you're multiplying an array of ints ( [Int]) with a simple Int (6). The compiler can't handle that and this is why Xcode is complaining that way.

So the best way to solve the problem is to create a for in loop from the number 1 to the number 10 instead of changing the Array result and to append the multiplier of the loop times 6.

Here is my code:

var results: [Int] = []
for multiplier in 1...10 {
    results.append(multiplier * 6)
}

Anthony

Ken Okiebisu
Ken Okiebisu
9,673 Points

Thank you for the reply! I will be needing some more practice but i've somehow managed to understand this question! Thanks for the help!