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 trialabdulmohsen abdullah
Courses Plus Student 352 Pointsim 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.
6 Answers
Mazen Wasel
1,256 PointsI 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
992 PointsThis is exactly what my problem was. Except instead of 'and', its 'times'. You have to really type exactly what they say.
Harold Davis
Courses Plus Student 14,604 PointsHey 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!
abdulmohsen abdullah
Courses Plus Student 352 PointsI 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
Harold Davis
Courses Plus Student 14,604 PointsI wonder if it's your keyboard?
abdulmohsen abdullah
Courses Plus Student 352 Pointsit appears when I type the comment but once I post my comment it disappear I don't know why
abdulmohsen abdullah
Courses Plus Student 352 Pointshello are you there ????
Harold Davis
Courses Plus Student 14,604 PointsSorry buddy was working I have to be honest I have no clue why your \is not working
Laksakan Krishnapillai
6,390 PointsI 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.
Saud Alfaris
1,084 PointsUse 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)"
Harold Davis
Courses Plus Student 14,604 PointsHey 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
Saud Alfaris
1,084 PointsI wrote it, I don't know why it is not added,,
abdulmohsen abdullah
Courses Plus Student 352 Pointsabdulmohsen abdullah
Courses Plus Student 352 PointsI 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