def encrypt_message(text, x):
text = list(text)
for y in text:
ord(text)
returns ord() expected a string of length 1, but list found
The problem is that you passed the text
to ord
function you need to pass the y
.
But as strings are iterable objects you can just loop over your string :
def encrypt_message(text, x):
return [ord(i) for i in text]