converting chr() / ord() with multi characters
<p>beginner programming in python (3.4)<br>
is it possible to pass multiple values inside chr() and ord()?
what i tried is the following:</p>

<pre><code>userInput = input('Please write your input: ')
&gt; Hello
result = ord(userInput) #here is the error because i put multiple values instead of just one
print(result)
</code></pre>

<p>this is the output i am looking for: <code>72 101 108 108 111</code> (hello) but instead i get an error telling me i can only pass 1 character/value inside chr() / ord()
is this possible? if not can you provide me in the right direction? thank you</p>

<p>You can use <code>map</code> function, in order to apply the <code>ord</code> on all characters separately:</p>

<pre><code>In [18]: list(map(ord, 'example'))
Out[18]: [101, 120, 97, 109, 112, 108, 101]
</code></pre>

<p>Or use <code>bytearray</code> directly on string:</p>

<pre><code>In [23]: list(bytearray('example', 'utf8'))
Out[23]: [101, 120, 97, 109, 112, 108, 101]
</code></pre>

<p>But note that when you are dealing with unicodes <code>bytearray</code> doesn't return a number like <code>ord</code> but an array of bytes values based on the passed encoding (a number between 0 and 256):</p>

<pre><code>In [27]: list(bytearray('â¬', 'utf8'))
Out[27]: [226, 130, 172]

In [25]: ord('â¬')
Out[25]: 8364
</code></pre>

python