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 Loops For In Loops

expected an argument list of type

Why is there an error when i use a multiplication operand in Int ?

loops.swift
// Enter your code below
var results: [Int] = []
for multiplier in 1...10{
print("\(results) times 6 is equal to \(results * 6)")
}

1 Answer

Luke Dawes
Luke Dawes
9,739 Points

Hi Brenda,

This Code Challenge is asking you to write a for-in loop that, for all the numbers between 1 and 10 inclusive, multiplies each number by six and then appends that number to the results array, which is an array of type Int.

In your code above, however, you're trying to multiply an empty array by six, which isn't quite what you're being asked to do. As far as I know, even if the array were full of numbers, you still wouldn't be able to multiply it by anything unless you treat each index item separately.

This passed for me in the Code Challenge, for both parts:

var results: [Int] = []

for multiplier in 1...10 {
  let correctAnswer = multiplier * 6
  results.append(correctAnswer)
}

For every multiplier in the range between 1 and 10, I'm assigning the value of that to a constant I created, correctAnswer, and then appending that to the results array. There are a few ways you can do this, but this worked for me. Hope that helps!