How to get key index dictionary from a string

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By User5080

i want to get the key index by using a string in dictionary:


i want it to give me the index of that key for example:

var fon = ["Hello","Apple"]


Can this be possible?

No, a dictionary isn’t ordered like this; it has a lookup based on the key, and may even reorder items based on its contents.

What are you doing where think you need an index?

spaceyjase | 2023-06-09 14:16

So i wanted to make weapon switching function
it only took 5 lines no more no less
but dont worry i found the solution:


It worked !!

User5080 | 2023-06-09 14:41

:bust_in_silhouette: Reply From: User5080



it gonna give you the key index but make sure that you entered an available key