if I have a list like this:
list1 = ['a', 'b', 'c', 'd']
How can I convert them to characters so I can get the ASCII codes?
if I have a list like this:
list1 = ['a', 'b', 'c', 'd']
How can I convert them to characters so I can get the ASCII codes?
With a list comprehension
codes = [ord(char) for char in list1]
From ord()
doc:
Given a string of length one, return an integer representing the Unicode code point of the character when the argument is a unicode object, or the value of the byte when the argument is an 8-bit string.