Inverse of method .get? Use of Dictionaries in Phyton | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Inverse of method .get? Use of Dictionaries in Phyton

Hi!, Is there a method of dictionaries for enter a value and that it returns the key of that value, the inverse of method .get?

4th Aug 2020, 2:54 AM
Oscar
Oscar - avatar
1 Answer
+ 2
There isn't a built in method to do this, but you could create a function to do so. Problem will be that there can be multiple keys that have the same value and the first one found is what would be returned (unless coded otherwise) and the order of which may not be guaranteed.
4th Aug 2020, 4:39 AM
ChaoticDawg
ChaoticDawg - avatar