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![](https://ecs-static.teamtreehouse.com/assets/views/marketing/shared/community-banner-white-47072046c51352fe6a69f5e691ff5700b28bb11d45197d7bdf066d9ea3f72d0c.webp)
![Ravi Soni](https://uploads.teamtreehouse.com/production/profile-photos/7009362/micro__MG_8915.jpg)
Ravi Soni
iOS Development Techdegree Student 1,123 PointsHOW it will work
Using string interpolation, create a string literal that describes the operation we just performed. For example, given the following values for firstValue, secondValue and product respectively: 2, 4, 8. The string should read: "The product of 2 times 4 is 8". Assign this string to a constant named output.
// Enter your code below
let firstValue = 2
let secondValue = 4
let product = firstValue * secondValue
let output = "\("The product of ") + \(firstValue) + \(" times ") + \(secondValue) + \(" is ") + \(product)"
1 Answer
![Ricardo Hill-Henry](https://uploads.teamtreehouse.com/production/profile-photos/134316/micro_6618D5BA-D290-40A7-ADA4-B0B5CC46FD2C.jpg)
Ricardo Hill-Henry
38,442 PointsHi Ravu! What you've done in your output variable is essentially an attempt at what string interpolation saves us from -- unneccessary concatenations (and more).
let output = "\("The product of ") + \(firstValue) + \(" times ") + \(secondValue) + \(" is ") + \(product)"
What you've tried reminds me of this:
let output = "The product of " + firstValue + " times " + secondValue + " is " + product."
I'll assume you have some previous programming experience, because that's what most of us would be used to (or worse).
With Swift's string interpolation, there's no need (in most cases) for those concatenation operators. The interpreter will search through your string to look for the special characters () similar to how it would do a comment, or escaped character.
let output = "The product of \(firstValue) times \(secondValue) is \(product)"