![](/img/trans.png)
[英]basically i am trying to do a python-sql connector program but at the moment i'm stuck with this error
[英]I'm trying to produce a line of code the returns the score of a word but at the moment I am getting an error
def getWordScore(word):
points_total = 0
for letter in word:
points_total += getLetterScore.get(letter,0)
return points_total
brownie_points = getWordScore("BROWNIE")
輸出 NameError: name 'word' 未定義
我對為什么會收到 nameError 感到有些困惑,有什么建議嗎?
適當的縮進應該可以解決問題
def getWordScore(word):
points_total = 0
for letter in word:
points_total += getLetterScore.get(letter, 0)
return points_total
brownie_points = getWordScore("BROWNIE")
請注意,您尚未提供getLetterScore
,因此可能存在其他一些問題
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.