Python scrabble_score

define a function scrabble_score that take a string word as input and returns the equivalent scrabble score for that word.
Assume your input is only one word containing no spaces or punctation.
Your function should work even if the letter you get are uppercase,lowercase,or a mix.

def scrabble_score(word):
total = 0
for x in word:
total += score[x.lower()]
return total

def scrabble_score(word):
return sum([score[x] for x in word.replace("","").lower() if x in score])

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 经常会感觉自己特别的LOW,没有什么特别喜欢的,没有什么特别精通的,没有什么难忘的记忆,没有什么伟大的旅行,没有特...
    刘阿文阅读 514评论 0 2
  • 桂花,送来数缕馨香。 秋雨,不痛不痒滴在心弦。 伊人,在雨中奔跑。 时间,堆在瘦弱的双肩上。 少年,忘在人潮中。 ...
    简宁思静阅读 164评论 0 0
  • 不知不觉已经到了五月份了,虽说武汉的天气以每天36种花样变化着,但还是阻挡不了夏天的来临。 上大学已经快一年了,平...
    宁夏思溢阅读 376评论 0 1
  • 蓝莓刚出生,医生护士们都很喜欢这个混血宝宝,来查房检查的时候都忍不住多看几眼。"她有双杏仁眼呢!" 实习小护士抱起...
    婳ManjiKids阅读 434评论 0 1