Basically, I'm creating a really low tier cipher. I've set up a bit of code to randomize each character, but I can't figure out how to replace a string with these. This is the code I attempted
characters = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z", ".", ",", " ", "!", "?"]
characters2 = ['h', 'i', '.', 'u', 'o', 'x', 'q', 'b', 'y', 'z', 's', 'd', 'm', 'w', 'k', 'n', 'j', '?', 'a', 'v', 't', 'r', 'e', 'f', 'c', ' ', '!', 'l', 'g', 'p', ',']
string = string.replace(characters[],characters2[])
In this example I was basically expecting being able to input a string, such as "string" and get back the encrypted string, which in this case would come back as "av?ywq". The only other way I could think of working this out would basically be to write
string = string.replace(characters[0],characters2[0]).replace(characters[1],characters2[1]).replace...
for the entire length of the list, which I could do, but it would be extremely tedious and take up way too much space.
Doing a loop would of course mean that if, for example, the "i" in "string" were replaced with an "s", and then the "s" in string were replaced with an "h", it would come out "htrhng", replacing both the "i" and "s" with the "h".
How would I go about solving this?