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 trialJulien Mayer
1,880 PointsI have been stuck on this exercise for two days now
, and I can not seem to figure out what I am doing wrong... Any ideas? :)
Thank you so much!
let currencies = ["US": "Dollar", "UK": "Pound", "JP": "Yen"]
let ukCurrency = currencies.removeValueforKey("UK")
2 Answers
miguelcastro2
Courses Plus Student 6,573 PointsJulien,
I think the challenge wants you to get the value from the dictionary of currencies. Each of our currencies are indexed using the counties code. To access the value we just need to reference the key which will then pull up our value.
// Declare our currencies dictionary
let currencies = ["US": "Dollar", "UK": "Pound", "JP": "Yen"]
// Access the value for the country UK
let ukCurrency = currencies["UK"]
For more information I recommend checking out Apple's official Swift documentation.
Let me know if this is what you were trying to achieve.
Julien Mayer
1,880 PointsThank you so much! that is exactly what I needed!
Julien
Julien Mayer
1,880 PointsThank you so much! that is exactly what I needed!
Julien
Ryan Jin
15,337 PointsIf the question asks you to delete the value, then you use remove value for key. If not, you don't remove the value. You simply just do this:
let currencies = ["US": "Dollar", "UK": "Pound", "JP": "Yen"]
let ukCurrency = currencies.["UK"]
Julien Mayer
1,880 PointsThank you so much Ryan!
I have now completed the Swift Basics, and I am ready to move on to the next category!
Julien
Julien Mayer
1,880 PointsJulien Mayer
1,880 Pointsby the way, I forgot to mention that the .removeValueforKey should have an uppercase letter for the word "for". This does not change the outcome of my code though... I still get it wrong every time.