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 Basics Swift Types Type Safety and Type Inference

im having a trouble with the format of the string

this is what wrote: unity

let firstValue = 2

let secondValue = 4

let product = 2 * 4

let output = " \(firstValue) \(secondValue) \(product)  "

MODERATOR EDIT: Added Markdown to post so the code is readable in the Community. Please refer to the Markdown Cheetsheat when posting to the Community for the proper markdown with code snippets.

I don't know why the backslash doesn't appear it didn't appear in interpolated challenge and it's not appearing now could someone please help

6 Answers

Mazen Wasel
Mazen Wasel
1,256 Points

I think the problem is that challenge editor is expecting you to type:

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

instead of:

let output = " (firstValue) (secondValue) (product) "

Willem Ostn
Willem Ostn
992 Points

This is exactly what my problem was. Except instead of 'and', its 'times'. You have to really type exactly what they say.

Hey Kong! when ever you are interpolating properties into a string like this you must use a \ before the () so for you this looks like:

let output = " \(firstValue) \(secondValue)  \(product) "

Hope this helps let me know if you have questions!

I don't know why the backslash doesn't appear it didn't appear in interpolated challenge and it's not appearing now could someone please help

I wonder if it's your keyboard?

it appears when I type the comment but once I post my comment it disappear I don't know why

hello are you there ????

Sorry buddy was working I have to be honest I have no clue why your \is not working

Laksakan Krishnapillai
Laksakan Krishnapillai
6,390 Points

I am having a problem on this question right now and I have formatted the string interpolation and I am not sure why it's incorrect.

Use this code: // Enter your code below let firstValue = 5 let secondValue = 6 let product = firstValue * secondValue let output = "The product of (firstValue) times (secondValue) is (product)"

Hey suad!

Try not to forget the \

So it looks like (variable) If the slash is not there then the compiler does not know you are using string interpolation.

-Harold

I wrote it, I don't know why it is not added,,