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 Printing Results

eric robinson
eric robinson
3,016 Points

It is not working for me. I wrote let language = "Swift" println("Learning \(language)") it says I'm wrong

why can't I see a correct version of the answer?

println.swift
let language = "Swift"
println("Learning  \(language)")
Traci McGrew
Traci McGrew
2,559 Points

The sample code you provided prints out "Swift" to the playground and then "Learning Swift" (you have an extra space between Learning and Swift) also to the playground. It also prints out "Learning Swift" to the console.

If you are typing it into the treehouse system in an exercise, is the code you provided the exact code you put in? Meaning did you copy it and put it on here in your question or did you retype it? Otherwise check to make sure you spelling "language" the same in both your variable declaration and when you use it as a variable in your print statement. Also make sure have the " " and ( ) in the right places and as many as you need. Typing it into the treehouse thing is easy to leave one off or put in wrong place especially when writing something more complicated and it doesn't prompt you like XCode does.

If everything is correct syntax wise, then double check you are giving it what it asked for in the way it asked for it. Some of the exercises ask for something specific (like it wanted you to write the print statement like this for some reason):

println("Learning " + language)

One of the other things you can do if you are still having problems is open a clean playground and do the exercise in there. When you have it working paste it into Treehouse. Every once in awhile I have also run into a problem where I did make a small mistake (like an ending } was mistakingly left off the end of a function because it doesn't create two for you automatically like XCode) and it told me it was wrong. I fixed it easily and resubmitted and it still didn't like it but I knew it was right now. I had to go back out and start the challenge again so it would reload and put it in again for it to take it. Doesn't happen often but it will. It will also happen if you get interrupted in the middle of a challenge and let it sit a second (to deal with a kid, run to the bathroom, answer the phone) it doesn't seem to disconnect you just won't work right and need to reload.

Anyway, hope you find some of this helpful.

1 Answer

kirkbyo
kirkbyo
15,791 Points

Hey Eric,

Your code is fine, but you added two spaces after learning.

println("Learning \(language)")

Remove one space after 'learning' and everything will be good.

Ozzie