Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def element_counter(hand):
- """Counts the number of elements in the hand"""
- sum = 0
- for i in hand.values():
- sum = sum + i
- return sum
- def play_hand(hand, word_list):
- word = ''
- total_score = 0
- letters_left = element_counter(hand)
- while word <> '.':
- if letters_left == 0:
- return
- print 'Current Hand:',
- display_hand(hand)
- print 'Enter word, or (.) to indicate that you are finished:',
- word = raw_input().lower()
- if word == '.':
- print 'Total score:', total_score, 'points.',
- return
- elif not is_valid_word(word, hand, word_list):
- print 'Invalid word, please try again.'
- else:
- score = get_word_score(word, HAND_SIZE)
- total_score += score
- print word, 'earned', score, 'points. Total:', total_score, 'points'
- hand = update_hand(hand, word)
- letters_left -= len(word)
- print "letters left", letters_left
Advertisement
Add Comment
Please, Sign In to add comment