给定一串单词,您需要找到得分最高的单词。
单词的每个字母根据其在字母表中的位置得分:a = 1, b = 2, c = 3等等。
您需要将得分最高的单词作为字符串返回。
如果两个单词得分相同,则返回原始字符串中最早出现的单词。
所有字母均为小写,所有输入均有效。
high('man i need a taxi up to ubud'), 'taxi'
代码看不懂,请解释1下
1.max里面为什么要x.split(), key=lambda k: sum(ord(c) - 96 for c in k,是比这两个的大小吗
2.k代表的是什么
def high(x):
return max(x.split(), key=lambda k: sum(ord(c) - 96 for c in k))
print(high('what time are we climbing up the volcano')) #'volcano'