Python Introducing Dictionaries Iterating and Packing with Dictionaries Recap of Iterating and Packing with Dictionaries

RIP' FINGALINS"""""""""
RIP' FINGALINS"""""""""
1,893 Points

Help can someone help me with this?

I need help! please help me now horse lips

Chris Freeman
Chris Freeman
Treehouse Moderator 58,954 Points

Can you be more specific on the help you need? Answers are among keys, values, items, True, False

1 Answer

Jeff Muday
MOD
Jeff Muday
Treehouse Moderator 23,705 Points

Hahahah "Horse Lips" that's pretty funny way to describe curly-braced dictionaries!

You should definitely practice using dictionaries-- they might seem confusing at first, but they are a very useful data representation and a way to bridge between JSON data formats so common with API results.

To access keys and values:

student = {'name': 'Craig', 'major': 'Computer Science', 'credits': 36}

for key, val in student.items():
    print(key)
    print(value)

To access just the keys:

student = {'name': 'Craig', 'major': 'Computer Science', 'credits': 36}

for key in student.keys():
    print(key)

To access just the values:

student = {'name': 'Craig', 'major': 'Computer Science', 'credits': 36}

for value in student.values():
    print(value)