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 trialBill Bruno
2,058 PointsHelp with your code challenge
For this code challenge, this is what I put. Works with Xcode but the code challenge says I am wrong. Please help me see what I am doing wrong and why does it work with Xcode?
let firstValue: Int = 20 let secondValue: Int = 24
let product = firstValue * secondValue let output = "("The product of ") (firstValue) ("times") (secondValue) ("is") (product)"
// Enter your code below
let firstValue: Int = 20
let secondValue: Int = 24
let product = firstValue * secondValue
let output = "\("The product of ") \(firstValue) \("times") \(secondValue) \("is") \(product)"
4 Answers
Zachary Kaufman
1,463 PointsDon't have ("") around your words. I think that will get it to pass. Hope this helps!
Zachary Kaufman
1,463 PointsHad that been a real life problem you would have passed because you were correct in your syntax. The only reason it didn't pass in the grader is because he was teaching how to input variable values into strings so the grader was searching for (variableName) inside of a set of " instead it got your solution of ("") and (variableName) so it counted it wrong. Good job and good luck with your classes!
zaid alqattan
2,206 Pointslet firstValue: Int = 20 let secondValue: Int = 24
let product = firstValue * secondValue
let output = "The product of (firstValue) times (secondValue) is (product)"
Grant Thomas
13,705 PointsIt looks like you're using the interpolation syntax wrong. You only want to interpolate your two constants. Not the entire string (Or strings in between) Try this:
let firstValue: Int = 20
let secondValue: Int = 24
let product = firstValue * secondValue
let output = "The product of \(firstValue) times \(secondValue) is \(product)"
Bill Bruno
2,058 PointsBill Bruno
2,058 PointsThank you. I will try that. I would have thought Xcode would have took an error on that as well. All new learning experience. Thanks again.