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) Collections What is a Dictionary?

Roger Green
Roger Green
643 Points

Confused

Let's create a dictionary that contains the currencies of the various countries along with their country codes. The country code will be the key and the currency the value. Using the following key-value pairs: US : Dollar, UK : Pound, JP : Yen assign them to a constant named currencies.

let currencies["US": "Dollars", "UK": "Pound", "JP", "Yen"]

4 Answers

David Curtis
David Curtis
11,301 Points

it should be "JP": "Yen". you have "JP", "Yen".

let currencies = ["US": "Dollar", "UK": "Pound", "JP": "Yen"]

Roger Green
Roger Green
643 Points

I feel so stupid lmao

It's a very easy mistake to make and especially miss, no need to feel stupid :)

David Curtis
David Curtis
11,301 Points

haha - hey man, i do this for a living. these types of bugs happen all the time! :D

hey David Curtis was hoping if you can help me with the extra credit question,please. it read: "Create an array of 10 songs where each song is a dictionary. The dictionary contains the following keys: title, artist and album." But confused about it because all the keys in the example took one value. can a key take on more values? and if so how would the syntax look like please?