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.

4th Jul 2018, 7:46 PM
Joseph.Atzinger
2 odpowiedzi
+ 2
#try num=[8,5,12,12,15] for i in num: print(chr(ord('a')-1+i),end='')
4th Jul 2018, 8:04 PM
Louis
Louis - avatar
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]
4th Jul 2018, 7:54 PM
TurtleShell
TurtleShell - avatar