how to translate to string to different alphabet python
text = input()
def encrypt(t):
chars = list(text)
allowed_characters = list(" abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789,.?!")
for char in chars:
for i in allowed_characters:
if char == i:
chars[chars.index(char)] = allowed_characters.index(i)
return chars
print(encrypt(text))
4.22
9
string = 'some string'
normal_alphabet = 'abcdefghijklmnopqrstuvwxyz.'
my_alphabet = 'ijklmnopqrstuvwxyz.abcdefgh'
translation = string.maketrans(normal_alphabet, my_alphabet)
print(string.translate(translation))
Thank you!
9
0
Are there any code examples left?
New code examples in category Python