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

Error : Your code couldn't be complied . But if run it in Xcode playground it runs nicely

let multiplier = 6 for table in 1...10 { print["(table) times 6 , which is equal to (multiplier*table)"]


// Enter your code below

let multiplier = 6
for table in 1...10 {
 Print["\(table) times 6 , which is equal to \(multiplier*table)"]


1 Answer

There are a few things.

  1. The constant on the for loop should be multiplier instead of times
  2. The task asks you too append the results array with the multiplier * 6

As for why it won't compile, this is just an assumption, but the coding emulator on the site may not support operations when doing string interloping. If you replace the print statement with the append property on the array it should compile.