Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

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,738 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!