Aug-01-2020, 03:39 PM
Greetings,im really new to python and im trying to create a simple encryption program (basically ill input a text and it'll get converted to numbers, nothing complicated for now). Heres my code so far:
a = 1 b = 2 c = 3 d = 4 e = 5 f = 6 g = 7 h = 8 #just random letters and their respective numbers fr = open('tryy.txt', 'r') fw = open('tryy.txt', 'a') for elem in fr: fw.write(elem.replace('a', str(a))) & fw.write(elem.replace('b', str(b))) fr.close() fw.close()the problem is that when i try using this, (my basic example text is just "ab"), instead of converting both characters to "12" as it should, the program returns a text file like this:
ab 1b a2any advice on how to correct the code here?