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 Collections and Control Flow Dictionaries in Swift Working With Dictionaries

my code does not run on the treehouse compiler but it runs on the xcode compiler i don't know why even though they are

i tried it on xcode and it works

dictionary.swift
// Enter your code below
var iceCreame = [" CC ": " chocolate chip ", " AP ": " Apple Pie ", " PB ": " Peanut Butter " ]

1 Answer

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Hi there! It is possible to write functional code that works in Xcode but yet does not meet the exacting requirements of the challenge. Just because it runs in Xcode without problem does not mean that you fulfilled what the challenge is asking for. In your case, you have a few things that are causing the challenge to fail.

First, you've misspelled the name of the variable holding the dictionary. The challenge requires that it be named iceCream, but you've typed iceCreame. Xcode doesn't care how you spell it, but the challenge checker is specifically checking for what is inside a specific variable.

Secondly, you have extraneous spaces around your keys and values. Take a look:

" CC ": " chocolate chip "

instead of

"CC": "chocolate chip",

Remember, that spaces inside strings also count as characters. So, " hello" is not the same as " hello" or "hello" or "hello ".

If you make these corrections, the challenge will pass.

Good luck, but let me know if you're still stuck! :sparkles:

thanks it worked