A community for students.

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

anonymous

  • 5 years ago

how to find key of a value in a dictionary

  • This Question is Closed
  1. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    excuse me, but why would you need that?.. the idea of dicts is using the keys as indexes to get values not the other way around..

  2. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    okk basically i want input from user and check it agaist my dictionary values and return key like this: dict={'windows':['win 7','xp','NT'],'linux':['ubuntu','fedora','mint'} and if user enter win 7 it returns windows and so on

  3. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    well you can do it, but you're implementing dictionaries wrong.. platform = {'windows' : ['win 7', 'xp', 'NT'], 'linux' : ['ubuntu', 'fedora', 'mint']} user_input = "xp" keys = platform.keys() for x in keys: for y in platform[x]: if y == user_input: print user_input I recommend that you restructure the dictionary, so that the versions or distros can be the indexes.

  4. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    thanks axl456 okk so now you know that this is the scene how would you use dict in this case? i could not understand the last line

  5. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    you could use them like this: operating_system = {"xp" : ["windows",], "win 7" : ["windows",], "NT" : ["windows",], "ubuntu" : ["linux",], "fedora" : ["linux",], "mint" : ["linux",]} in this case every windows version or linux distro is an individual entry in the dict. This way you can add more info to every entry: operating_system = {"xp" : ["windows", "2001", "128 MB RAM", "1.5 GB"]... and use the OS as index, so if the user type "xp" you could just do this: operating_system[user_input]

  6. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    thanks bro.. well i want to very familiar with dictionary and list its mutations how can i do that is there any book or something its really tough to make simple projects for beginners because as a programmer of C i know what i want to do but i can't implement it in python

  7. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    well for python theres A LOT of book, videos, tutorial, etc etc on the internet.. the one I recommend most is this: http://www.amazon.com/Learning-Python-Powerful-Object-Oriented-Programming/dp/0596158068

  8. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    thanks but i dont have credit card yet.. :( well where can i find videos apart from MIT 6.0

  9. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    i have one book of python beginning python (wrox publication) is it good enough?

  10. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    I havent seen this videos yet, but they look good: http://code.google.com/edu/languages/google-python-class/ this is the one of dict: http://www.youtube.com/watch?v=haycL41dAhg

  11. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    thanks bro thanks a lot.. :) do you have facebook a/c?

  12. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    yes, I never use it but I have one.. is /Fidel.sanchez.bueno

  13. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    thanks well the google video starts from part3 i wondor where are the other 2 parts from day1

  14. anonymous
    • 5 years ago
    Best Response
    You've already chosen the best response.
    Medals 0

    http://code.google.com/edu/languages/google-python-class/ on the left in "Lecture Videos"

  15. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Sign Up
Find more explanations on OpenStudy
Privacy Policy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.