Creating a bijection between integers and a set of strings
Since what you want is something a little more complicated than what a normal dictionary can do, I think you want to encapsulate all of this in a class that behaves the way you want the dict to behave.  You can make it "look like" a dict by implementing __getitem__, something like:

from typing import Dict, List, Set, Union, overload


class StringTable:
    """Associate strings with unique integer IDs."""

    def __init__(self, strings: Set[str]):
        """Initialize the string table with the given set of strings."""
        self._keys: List[str] = []
        self._ids: Dict[str, int] = {}
        for key in strings:
            self._ids[key] = len(self._keys)
            self._keys.append(key)

    @overload
    def __getitem__(self, o: int) -&gt; str: ...

    @overload
    def __getitem__(self, o: str) -&gt; int: ...

    def __getitem__(self, o: Union[int, str]) -&gt; Union[str, int]:
        """Accepts either a string or int and returns its counterpart."""
        if isinstance(o, int):
            return self._keys[o]
        elif isinstance(o, str):
            return self._ids[o]
        else:
            raise TypeError("Bad argument!")

    def __len__(self) -&gt; int:
        return len(self._keys)


Now you can use it like:

strings = {"foo", "bar", "baz"}
bijection = StringTable(strings)
for s in strings:
    print(s, bijection[s])
    assert bijection[bijection[s]] == s


etc.