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 trialAdam Čevela
567 PointsHi, Please can somebody help me what is wrong with my code?
Assign the value for key "UK" to a constant named ukCurrency.
let currencies = ["US": "Dollar", "UK": "Pound", "JP": "Yen"] let ukCurrency = ["UK"]
let currencies = ["US": "Dollar", "UK": "Pound", "JP": "Yen"]
let ukCurrency = ["UK"]
2 Answers
Nick Jones
2,086 PointsHi Adam
What you're after would be the following:
let currencies = ["US": "Dollar", "UK": "Pound", "JP": "Yen"]
let ukCurrency = currencies["UK"]
The reason for this is that in the code you've posted you're creating a new constant named "ukCurrency" and then implicitly making it a dictionary containing only the value "UK" as it doesn't reference the dictionary that you previously created which you aptly named "currencies" The above code is very similar to what you've got with the key difference being that it calls currencies first and then says "Hey I've got this key named "UK", can I have the value for it please" and the currency constant then provides "Pound" as desired.
I hope that helps :) Any problems just let me know!
Steve Hunter
57,712 PointsYou need to refer to the dictionary you created in the first line:
let ukCurrency = currencies["UK"]
Adam Čevela
567 PointsAdam Čevela
567 PointsAlright thanks a lot :))