Reputation: 21
def toNumbers(strList):
sum = 0
strList[:]= (ord(ch)-96 for ch in strList)
print(strList)
def main():
print("Modifies each entry in the list by converting it to a number.")
strList = [ "dd", "t", "c"]
nums= toNumbers(strList)
main()
I get an error : ord expected a character. I think this is something to do with my for loop. Any assistance on this would be great.
Upvotes: 0
Views: 828
Reputation: 16942
You really should read your error messages a little more carefully. What it actually said was
TypeError: ord() expected a character, but string of length 2 found
And your string of length 2 is "dd"
.
Upvotes: 1