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 String Manipulation

NAVEED CHOWDHURY
NAVEED CHOWDHURY
1,142 Points

let name = "Naveed" let greetings = "Hi there,\(name)" Why is this code not working ?

Want to know what would be the right way to write this code since I am getting error

strings.swift
// Declaring my name

let name = "Naveed"
let greetings = "Hi there,\(name)"

1 Answer

andren
andren
28,558 Points

Challenges are very picky about names and strings, you usually have to name things and format the strings to look exactly the way the challenge requests. Even the tiniest of differences will often mark the code as wrong, even if it technically runs and works just fine.

The specific issues in your case is that you have named the variable greetings rather than greeting which is the name the task specified, and you are missing a space after the comma within the string. If you fix those issues like this:

let name = "Naveed"
let greeting = "Hi there, \(name)"

Then your code will pass the first task.

NAVEED CHOWDHURY
NAVEED CHOWDHURY
1,142 Points

Hi Andren, thanks for your very helpful comment. It worked now guess I was not following the instructions 100% correctly. Will try to remember that.