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

How do I format the constant that multiplies firstValue and secondValue and reveals the end product? Swift 3.0

I am working on a challenge so I can move on. The first task was to assign constants so I entered "let firstValue: Int = 10" and the second "let secondValue: Int = 50" and then the second task was to assign a constant named product that multiplied the values together so i entered "let product = firstValue*secondValue" but now the third task is to use string literal to interpolate the values and products together. "let output: String = "(firstValue) (secondValue) (product)" this is how i formatted it and it is wrong. I do not know how to format this task so that I can move on, can you help me?

types.swift
// Enter your code below
let firstValue: Int = 10
let secondValue: Int = 50
let product = firstValue*secondValue
let output: String = "\(firstValue)*\(secondValue) = \(product)"

2 Answers

David Papandrew
David Papandrew
8,386 Points

Hi Heather,

You have the right idea, but you need to incorporate literal string text alongside the interpolated values in order to generate the exact output the challenge wants.

Specifically:

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

THANK YOU!!

David's answer is exactly right. For your reference, the final code challenge should be

let firstValue: Int = 10
let secondValue: Int = 50
let product = firstValue * secondValue
let output = "The product of \(firstValue) times \(secondValue) is \(product)."