Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

iOS Swift Basics (retired) Collections What is a Dictionary?

Josh Bradford
Josh Bradford
9,935 Points

Can't figure out why I am not getting this code right, can anyone help? I am suppose to assign value for key to constant

I believe I have the code correct but it is not passing me through. It keeps giving errors. Has anyone had this same problem? Any help would be great, thanks in advance.

dictionaries.swift
let currencies = ["US": "Dollar", "UK": "Pound", "JP": "Yen"]
let ukCurrency = currencies.removeValueForKey("UK")

1 Answer

Josh Bradford
Josh Bradford
9,935 Points

It worked like a charm, man, thank you so much for the help!

Just like you said. When retrieving a value from a dictionary, use this example: ``` let greeting: String = ["Hello": "Formal", "Hey": "Irrformal"] let formal: String = greeting["hello"]