How to get a dictionary key from its value

Godot Version

v4.2.1.stable.mono.official [b09f793f5]

Question

Very simple question
I have a dictionary where all the keys are strings and the values are Vector2 sets. Is it possible to get one of these string keys by passing in a Vector2?

My intuition was to do my_dict.keys()[value], but that doesn’t work. Hopefully the failed attempt makes it a bit more clear what I was trying to do :stuck_out_tongue:

var key = my_dict.find_key(value)

Oh that’s really simple. I dunno how I didn’t notice that was a thing; thanks!

1 Like