I have been trying to make something like an encoder:
here is my idea
dict = {
1: "!",
2: "@"
}
in = 21 # Input number in
out = ?
print(out) # Returns "@!"
Is there any way I could perform this?
What you want is exactly the translate function of str:
x="12"
y="!@"
in=12
txt=str(in)
mapping = txt.maketrans(x, y)
out=txt.translate(mapping)
You can check the complete reference here.