Пример #1
0
def calc_word_value(word):
    """Calculate the value of the word entered into function
    using imported constant mapping LETTER_SCORES"""
    sum = 0
    for c in word:
        sum += LETTER_SCORES.get(c.upper(), 0)
    return sum
Пример #2
0
def calc_word_value(word):
    score = 0
    for letter in (l.upper() for l in word):
        score += LETTER_SCORES.get(letter, 0)
    return score
Пример #3
0
def calc_word_value(input):
    """Calculate the value of the word entered into function
    using imported constant mapping LETTER_SCORES"""
    return ft.reduce(lambda x, y: x + LETTER_SCORES.get(y.upper(), 0), input,
                     0)
Пример #4
0
def calc_word_value(word):
    """Calc a given word value based on Scrabble LETTER_SCORES mapping"""
    return sum(LETTER_SCORES.get(char.upper(), 0) for char in word)
Пример #5
0
def calc_word_value(word):
    """Calc a given word value based on Scrabble LETTER_SCORES mapping"""
    return sum(LETTER_SCORES.get(char.upper(), 0) for char in word)
Пример #6
0
def calc_word_value(word):
    return sum(LETTER_SCORES.get(char.upper(), 0) for char in word)
Пример #7
0
def calc_word_value(word):
    """Calculate the value of the word entered into function
    using imported constant mapping LETTER_SCORES"""
    values = [LETTER_SCORES[letter.upper()] for letter in word if
                letter.upper() in LETTER_SCORES.keys()]
    return sum(values)
Пример #8
0
def calc_word_value(word):
    """Calculate the value of the word entered into function
    using imported constant mapping LETTER_SCORES"""
    return sum(LETTER_SCORES.get(char, 0) for char in word.upper())
Пример #9
0
def calc_word_value(word):
    """Calculate the value of the word entered into function
    using imported constant mapping LETTER_SCORES"""
    return sum(LETTER_SCORES.get(letter.capitalize(), 0) for letter in word)
Пример #10
0
def calc_word_value_with_reduce(word):
    return reduce(
        (lambda accum, char: accum + LETTER_SCORES.get(char.upper(), 0)),
        list(word), 0)
Пример #11
0
def calc_word_value(word):
    """Calculate the value of the word entered into function
    using imported constant mapping LETTER_SCORES"""
    # Creates a list of numbers based the word arg and values per letter
    # Sums then returns total word value
    return sum(LETTER_SCORES.get(char.upper(), 0) for char in word)
Пример #12
0
def calc_word_value(thestr):
    """Calculate the value of the word entered into function
    using imported constant mapping LETTER_SCORES"""
    letter_scores = [LETTER_SCORES.get(char.upper(), 0) for char in thestr]
    return sum(letter_scores)
Пример #13
0
def calc_word_value(word):
    #Calculate the value of the word entered into function using imported constant mapping LETTER_SCORES
    return sum(LETTER_SCORES.get(letter.upper(), 0) for letter in word)