How to translation table using a dictionary with maketrans() in Python

2 Answers

0 votes
dict = {"a": "23", "b": "98", "c": "9372", "d": "5"}

string = "abcd"

print(string.maketrans(dict))
  
 
        
'''
run:
 
{97: '23', 98: '98', 99: '9372', 100: '5'}
        
'''

 



answered Apr 30, 2020 by avibootz
0 votes
dict = {97: "23", 98: "98", 99: "9372", 100: "5"}

string = "abcd"

print(string.maketrans(dict))
  
 
        
'''
run:
 
{97: '23', 98: '98', 99: '9372', 100: '5'}
        
'''

 



answered Apr 30, 2020 by avibootz
...