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 (retired) Types Numbers

Jason Demetillo
Jason Demetillo
428 Points

Trying to create a constant called price and assign it the value 9.99.

I have it down as let price = "9.99" and it's saying its wrong, a bit confused as I thought I'm assigning that value?

numbers.swift
let price = "9.99"

5 Answers

Is the var str = "price" supposed to be there? Shouldn't your answer just be:

let price = 9.99
Jason Demetillo
Jason Demetillo
428 Points

That's what I thought, but it still says it couldn't compile it...

I think I've figured it out! You removed the line from the first challenge. This should work:

let title = "A Dance with Dragons"
let price = 9.99

They want you to assign it the value 9.99 as a float, but you're trying to assign it as a String.

This is the answer they were looking for. Notice how I removed the quotation marks.

let price = 9.99

If you have any more questions feel free to tag me by putting @NickJanes and clicking on my name!

Jason Demetillo
Jason Demetillo
428 Points

Nick Janes Hey Nick I have this down and it's still telling me I'm wrong?

var str = "price"

let price = 9.99

What is the question you're trying to answer?

Jason Demetillo
Jason Demetillo
428 Points

Nick Janes it's asking Next create a constant called price and assign it the value 9.99.

Jason Demetillo
Jason Demetillo
428 Points

Agh I Got it Nick Janes ...it needed the previous code from before to make it complete, thanks so much again

var str = "title" let title = "A Dance with Dragons"

let price = 9.99

Ahh you beat me to it!