# [closed] HW- 5.4 Please Clear .

 1 Hello, Can anybody tell me how can we get the value of a <"keyword"> when we have its <"value"> ? Till now , we been doing its reverse. So this thing is kinda new to me. asked 24 Mar '12, 14:43 Estilo 151●5●10●26 accept rate: 0%

### The question has been closed for the following reason "The question is answered, right answer was accepted" by Estilo 24 Mar '12, 16:07

 0 Don't forget all the list handling we've been doing for a while. Not because we now know dictionaries that everything else is not good anymore... With a dictionary we can get the content by giving the keywork directly (dict[keyword]), which is cool, but we can still enumerate the keys as keywords in lists. answered 24 Mar '12, 14:47 Angel 7.0k●6●32●112 But list operations are fail on dictionary. (24 Mar '12, 14:50) Estilo Hmm now that I look at it again, I must admin I used a method on the dictionary that has net been covered yet... Which I changed after @yoshi's comment. There are similarities between lists and dictionaries. (24 Mar '12, 14:58) Angel
 0 Try using a for loop to go through all the keywords. For some inspiration, take a look at the example given in the homework. def courses_offered(courses, hexamester): res = [] for c in courses[hexamester]: res.append(c) return res  answered 24 Mar '12, 15:07 yoshi 4.0k●8●26●59 But this implies we have the hexamester, which we don't... (24 Mar '12, 15:14) Angel 1 True, but this is one level into the dictionary. You can always just do for hexamester in courses:  and traverse the hexamesters through that, just like you would for a list. (24 Mar '12, 15:16) yoshi Yeah! I am still not getting the idea of knowing 'keyword' when I have its 'value'. :/ (24 Mar '12, 15:17) Estilo Think about it from the list point of view, how would you get all the keywords if you knew the url? (24 Mar '12, 15:21) yoshi @yoshi Doh! /facepalm @Estilo go from what yoshi wrote (comment). Test key's value against your value.... (24 Mar '12, 15:24) Angel
 -1 OMG! Finally I got it. :/ It took me 1 hour. One things is for sure. Dictionary is really new to me. Thanks a lot @yoshi and @angel answered 24 Mar '12, 15:32 Estilo 151●5●10●26 Glad answers were helpful! (24 Mar '12, 15:33) Angel I would have got it in few mins but I just ignored the main key that I was sure of . LOL (24 Mar '12, 15:34) Estilo You're welcome :) (24 Mar '12, 15:40) yoshi

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "Title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported

×15,307
×1,718
×57
×18
×5