0
How do I translate numbers into letters? (beginner, simple code)
Hi there, Im new to coding and i am trying to translate Numbers into letters. Therefore i want to use two lists: num and abc Num contains a set of numbers, in my example it is [8,5,12,12,15] => "hello" abc contains the alphabet. (I coded something similar to the code in sequence python3 control strucures for loops 11/12 first page) However, there seems to be a problem with the counter used in the code. I am very grateful if somebody can help me with this simple issue. Thanks for helping.
2 Antworten
+ 2
#try
num=[8,5,12,12,15]
for i in num:
print(chr(ord('a')-1+i),end='')
0
If the letter string/list is in order then its as simple as taking away 1 from the number and use it as an index...
letter = abc[num - 1]