message = str(input())
for i in message:
if i == "a": i = 1
if i == "b": i = 2
print(i)
ect. I am trying to create a code generator where the user inputs a string eg. "hello" and it is converted to a number code by assigning each letter a number, based on their position in the alphabet. 1 = a, 2 = b and so on. The method I am currently using is very long - are there other ways to do this to avoid this issues?
How can I print the answer together, without the numbers being on multiple lines eg. 1 2 3 21 19
Aucun commentaire:
Enregistrer un commentaire