Why does the following code not output the corresponding letters correctly?
It outputs number to letter is['\x03', '\x03']
final_numbers = [3, 3]
final_letters = []
for i in range(len(final_numbers)):
print(i)
number_to_letter=chr(final_numbers[i])
final_letters.append(number_to_letter)
print ("number to letter is" + str(final_letters))
chr(3)
returns the character whose ASCII code is 3 (which is '\x03').To convert number to string (int-str) You have to do
str()
notchr()
So do like this:
Or this if you want to do
chr()
(try to guess what the results are)