python - How am I able to change this so the substituting works? -


The clues file contains 2 letters, and I want to move the second letter in the text file instead of the first letter. This changes the text file only 3 times, there is no change in it.

This clue is in the text file:

KM

OQ

Easy

< P> and this text is in the text file:

GFMNC wms BGLL RPLCeric GR zw filab Rfyrq ufyr amknsrcpq ypc dmp BMLG GR jid JW FELB GC Glockgagcler YLB RFIIFIFFF RFGAP RCVR GC QM JMLay Sqgle qrpgle.kyicrpylq () gq pcamkkclbcb LMU ynnjw ML RFC SPJ

and my code:

  import string def Convert (): cluesDict = {} open ('Clues.txt', 'r') clues = f.readlines () f = open ('Text.txt', 'r') text = f ('Clues.txt') with c: f = open. For clues for read () z: text.maketrans (z [0], z [1]) print (text)  

Can you tell me how to fix it?

There are two problems with your code: First, the first is that Matrron translates , But does not execute it. You should change that code to:

  text.maketrans (z [0], z [1]) print (text.translate (trans)  
< P> The other problem is that the clues are upper case, while the text is a short case when you are reading it, then by changing the clue, you can correct it:

  clues = [clue.lower For clues in () f.readlines ()]  

Instead, if you want to work both for leads and upper case, then you can: / P>

  text.maketrans (z [0] .model () + Z [0]. More (), jade [1] .low And () + Z [1] .More ()) print (Tekstktronslet (trans))  

Comments