-1

I'm trying to make an ASCII to string converter (not sure if that is correct terminology) using chr() but when I type in something like 68 (capital D), nothing happens. I'm trying to accomplish it using this idea:

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

I want it to run as a program with user defined input so I came up with this:

templist = []
number = int(input("Please enter an ASCII number here: "))
templist.append(number)
''.join(chr(i) for i in templist)

As I said above however, when I enter a value, nothing happens.

Any help is greatly appreciated.

EDIT: I have tried printing templist but it just gives me back the number I want to be converted to characters (68).

  • In first case you're using REPL. In second, you're running custom script. In REPL last evaled value is printed implicitly. In script you need to print it explicitly. – Łukasz Rogalski Nov 03 '16 at 16:07

1 Answers1

0

I needed to put ''.join(chr(i) for i in templist) in a print statement so the code would look like this

templist = []
number = int(input("Please enter an ASCII number here: "))
templist.append(number)
print(''.join(chr(i) for i in templist))