python letter to number code example
Example 1: python string replace letters with numbers
from string import ascii_letters
code = code = "1111702460830000Lu05"
code = "".join([str(ascii_letters.index(c)) if c in ascii_letters else c for c in code])
print(code)
Example 2: turn characters to alpgabetic numper 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))
Example 3: how to translate to string to different alphabet python
string = 'some string'
normal_alphabet = 'abcdefghijklmnopqrstuvwxyz.'
my_alphabet = 'ijklmnopqrstuvwxyz.abcdefgh'
translation = string.maketrans(normal_alphabet, my_alphabet)
print(string.translate(translation))