Conversation
beccaelenzil
left a comment
There was a problem hiding this comment.
Nice work! It's great that you used this opportunity to explore OOP and refactor. Great work using a branch for this refactored work. Your code is clear and logical. I've left a few inlines comments on ways you might consider refactoring, but overall, great work!
| if remaining_letters_count >= 10: | ||
| # do this 10 times: |
There was a problem hiding this comment.
Consider whether these if is necessary. I supposed if we had less than 10 letters in the LETTER_POOL this would help us avoid an index error, but we may want to deal with that edge case in a different way such as
if len(LETTER_POOL) < 10:
return "LETTER_POOL is too small"
or maybe not -- just something to consider :)
| # add letter to list | ||
| chosen_letters.append(drawn_letter[0]) | ||
| # decrease letter pool count by 1 | ||
| LETTER_POOL[drawn_letter[0]] -= 1 |
There was a problem hiding this comment.
We should make a copy of the LETTER_POOL so that our function does not directly modify this constant.
| if not isinstance(word, str) and len(word) <= 10: | ||
| return False | ||
| # if word is valid | ||
| for char in word.upper(): |
There was a problem hiding this comment.
Clear, logical code!
| pass | ||
| # checks to make sure that word is composed of elements in letter_bank | ||
| letter_bank_copy = letter_bank[:] | ||
| if not isinstance(word, str) and len(word) <= 10: |
There was a problem hiding this comment.
I am not quite sure what this check is doing. A comment to explain this validation check would enhance readability.
| high_score = max(word.score for word in list_of_word_objects) | ||
| high_score_words = [word for word in list_of_word_objects if word.score == high_score] | ||
| if len(high_score_words) > 1: | ||
| return tie_breaker(high_score_words, high_score) |
There was a problem hiding this comment.
Great work encapsulating this functionality in a helper function.
| if word.length == 10: | ||
| return word.word, score | ||
| # otherwise return shortest word | ||
| winning_word = min(word_list, key= lambda w: w.length) |
| high_score = max(word.score for word in list_of_word_objects) | ||
| high_score_words = [word for word in list_of_word_objects if word.score == high_score] |
Project submission