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 2.0 Basics Swift Types Recap: Swift Types

lata sharma
seal-mask
.a{fill-rule:evenodd;}techdegree
lata sharma
iOS Development Techdegree Student 5,292 Points

Swift 2.0 Task 2 of Integers & Floats

what am I doing wrong? // Enter your code below let firstValue = 7 let secondValue = 3 let product = firstValue * secondValue

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

types.swift
// Enter your code below
let firstValue = 7
let secondValue = 3
let product = firstValue * secondValue

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

1 Answer

Steven Deutsch
Steven Deutsch
21,046 Points

Hey lata sharma,

The problem is that you use String Interpolation when you want to extract the value from a variable or constant and place it inside of a string literal. A string literal is a sequence of characters beginning and ending with quotes. Such as "This is a string literal". Therefore, to create your output string you only need one set of quotes. The values that are not strings and are stored in a variable/constant you will use String Interpolation to add extract and add them to your String literal.

// Enter your code below
let firstValue = 7
let secondValue = 3
let product = firstValue * secondValue

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

Hope this helps. Good Luck!