Bokep
- Viewed 3k times2answered Dec 23, 2015 at 3:59
Are you using Python 2.7 or Python 3?
If you're using 2.7, then you need to use raw_input(), since input() is equivalent to eval(raw_input()), which you probably don't want:
name = raw_input("enter a name: ")If you're using 3, then print needs to be a function:
print(dict[name])...print("no data")However, common to both versions, some fixing needs to be applied.
First thing is, you don't need to use has_key(). I'm pretty sure this is defunct now, so the most pythonic way to go around this is do:
if name in percentage:Content Under CC-BY-SA license - See results only from geeksforgeeks.org
Python Dictionary get() Meth…
Python Dictionary get() Method returns the value for the given key if present in the …
Get key from value in Dictio…
This code finds the key of a given value in a dictionary by using a list comprehension …
Get specific keys' values
Dictionary is quite a useful data structure in programming that is usually used to …
Get Keys and Values from a Dictionary in Python - Stack Abuse
- Question & Answer
Get a value from a dictionary by key in Python | note.nkmk.me
- People also ask
WEBMay 28, 2024 · To get dictionary value by key in Python, use the get() function and pass the key to find its value. You can also get value by key using the index operator. Let’s find out with the examples given below.
Python Dictionary get() Method - GeeksforGeeks
Iterate through dictionary keys and values in Python
Python | Get key from value in Dictionary - GeeksforGeeks
Get key from value in dictionary - PythonForBeginners.com
Access Dictionary Values | Python Tutorial - GeeksforGeeks
How can I get dictionary key as variable directly in Python (not by ...
Python Dictionary Find Key By Value - Python Guides
Get the Value of a Key From a List of Dictionaries With Python
5 Best Ways to Get a Key From a Value in a Python Dictionary
python - Getting a list value from key/value pair - Stack Overflow
Python Mappings: A Comprehensive Guide – Real Python
Finding key from value in Python dictionary: - Stack Overflow
sqlite3 — DB-API 2.0 interface for SQLite databases - Python
Python | Get specific keys' values - GeeksforGeeks
How to get the key from value in a dictionary in Python?
Related searches for python get value from key