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