Answers for "dictionary get value from key"

0

get a value from a dictionary python

#!/usr/bin/python

dict = {'Name': 'Zabra', 'Age': 7}
print "Value : %s" %  dict.get('Age')
print "Value : %s" %  dict.get('Education', "Never")
Posted by: Guest on November-30-2020
0

get key from a value

person = {'name': 'Phill', 'age': 22}

print('Name: ', person.get('Phill'))
print('Age: ', person.get('age'))

# value is not provided
print('Salary: ', person.get('salary'))

# value is provided
print('Salary: ', person.get('salary', 0.0))
Posted by: Guest on February-01-2021

Code answers related to "dictionary get value from key"

Python Answers by Framework

Browse Popular Code Answers by Language