如果A-Z分别对应数字1-26,例:A:1
A B C D E F G H I J K L M N O P Q R S T U V W X Y Z
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
alphabet_dict =
{A: 1, B: 2, C: 3, D: 4, E: 5, F: 6, G: 7, H: 8, I: 9, J: 10, K: 11, L: 12, M: 13, N: 14, O: 15, P: 16, Q: 17, r: 18, s: 19, T: 20, U: 21, V: 22, W: 23, X: 24, Y: 25, Z: 26}
alphabet=ABCDEFGHIJKLMNOPQrsTUVWXYZ alphabet_dict={} for i in range(len(alphabet)): alphabet_dict[alphabet[i]]=i+1 print(alphabet_dict) def magic_word(word): s = 0 for i,x in enumerate(word.lower()): s += alphabet_dict.get(x) return word + 的幸运总数是:, + s for w in word_total: print(magic_word(w))(love 的幸运总数是:, 54)
(Knowledge 的幸运总数是:, 96)
(Hardwork 的幸运总数是:, 98)
(Health 的幸运总数是:, 54)
(luck 的幸运总数是:, 47)
(money 的幸运总数是:, 72)
(attitude 的幸运总数是:, 100)
英文字母的演变历史
验证中,请稍候… …
Hard work (努力工作)
8 1 18 4 23 15 18 11 = 98%
Knowledge(知识) = 96
11+14+15+23+12+54 +7+5 = 96%
Love 爱 = 54
L O V E:12 15 22 5 = 54%
Health(健康) = 54%
Luck(好运)L U C K:12 21 3 11 = 47%
MONEY 财产M O N E Y = 13 15 14 5 25 = 72%
attitude 态度的幸运总数是:100
活着的态度最重要,这碗鸡汤算是得来不易啊
追踪前沿权威的编程PBL课程