How To convert a list of ASCII values to a string in python?

Use map instead of the list comprehension:


>>> L = [104, 101, 108, 108, 111, 44, 32, 119, 111, 114, 108, 100]
>>> ''.join(map(chr,L))
'hello, world'



def working_ascii(): """ G r e e t i n g s ! 71, 114, 101, 101, 116, 105, 110, 103, 115, 33 """

hello = [71, 114, 101, 101, 116, 105, 110, 103, 115, 33]
pmsg = ''.join(chr(i) for i in hello)
print(pmsg)

for i in range(33, 256):
    print(" ascii: {0} char: {1}".format(i, chr(i)))
working_ascii()




Learn More :