I'm creating a simple cryptography project for school. I'm working with Python.
Target: user enters string, e.g. hello world!
I'll have to convert it into an array: space=0, a=1, b=2, ... z=26, .=27, ,=28, ?=29 and !=30
I use a dictionary:
dict = {' ': 0, 'a': 1, 'b': 2, 'c': 3,...}
My code
def messageToCode(message):
xarray = [None]
length = len(message)
ctr = 0
while not ctr == length:
xarray.append = dict[message.charAt(ctr)]
ctr = ctr + 1
return xarray
This won't work. Any suggestions?