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()
我收到错误:ord期待一个角色。我认为这与我的for循环有关。对此的任何帮助都会很棒。
答案 0 :(得分:1)
你真的应该仔细阅读你的错误信息。它实际上说的是
TypeError: ord() expected a character, but string of length 2 found
长度为2的字符串为"dd"
。