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 Basics Swift Types Recap: Swift Types

having trouble with the final exercise

when I click submit work it says my output is in the wrong format, can anyone help

types.swift
let firstValue = 2
let secondValue = 4
let product = 2 * 4
let output = " \(firstValue) \(secondValue) \(product)  "

3 Answers

ceriannejackson
ceriannejackson
23,759 Points

You're outputting the 3 variables in a string but not in the format specified which is

"The product of 2 times 4 is 8"

Matt Skelton
Matt Skelton
4,548 Points

You're very nearly there! Pay particularly close attention to this statement:

The string should read: "The product of 2 times 4 is 8"

You just need to tweak what you're displaying in your output. Your current output would print as follows:

" 2 4 8 "

You want the value of output to read as a grammatically correct statement. Once you add these details around your string interpolation, you'll be done. Hope that helps!

Hi I tried this code and it still won't work. By the way thank you for your excellent reply

"The product of (firstValue) times (secondValue) is (product)"

Matt Skelton
Matt Skelton
4,548 Points

Almost, you just need to add an extra character before your variable names to show that you want to retrieve the value that is stored within them.

let output = "The product of \(firstValue) times \(secondValue) is \(product)"

Without the backslashes, your output value will literally contain "The product of (firstValue) times (secondValue) is (product)". The backslashes are used to grab the value of a given variable and use that instead. This is known as string interpolation.

Hope this does the trick for you, good luck!