miscellaneous topics iii the deepcopy method is used in this type of situation to only copy the values and not the references here is how it would workfrom copy import deepcopy deepcopy( more with strings there are few more facts about strings that we haven' yet talked about translate the translate method is used to translate stringscharacter-by-character the translation is done in two steps firstuse maketrans to create special kind of dictionary that defines how things will be translated you specify an ordinary dictionary and it creates new one that is used in the translation then pass that dictionary to the translate method to do the translating here is simple exampled str maketrans(' '' '' '' '}print'abaab translate( )the result is ' here is an example where we use translate to implement simple substitution cipher substitution cipher is simple way to encrypt messagewhere each letter is replaced by different letter for instancemaybe every is replaced by gand every by an xetc here is the codefrom random import shuffle create the key alphabet 'abcdefghijklmnopqrstuvwxyz list(alphabetshuffle(lcreate the encoding and decoding dictionaries encode_dict str maketrans(dict(zip(alphabetl))decode_dict str maketrans(dict(zip(lalphabet))encode and decode 'this is secret 'this is secret translate(encode_dictt translate(decode_dictprint(alphabet'join( )tssep'\ 'abcdefghijklmnopqrstuvwxyz qjdpaztxghuflicornkesyvmwb exgk gk kadnae this is secret the way it works is we first create the encryption keywhich says which letter gets replaced withb gets replaced withetc this is done by shuffling the alphabet we then create translation