Conversation
audreyandoy
left a comment
There was a problem hiding this comment.
Great work Symone and Cassie!
Your submission covers all the learning goals and passes all the tests! Overall, the code was clean and easy to read. This project is definitely worthy of a green grade 🟢 🌲✨
My feedback primarily focuses on ways to declutter functions, utilize dictionaries to improve performance, and maintain data types for variables. I also loved all the docstrings and comments, they were definitely helpful in understanding your thought process for these solutions.
Keep up the great work 🌲 ✨
|
|
||
| # Hand draw logic, including incrementer and non-zero value check | ||
| while hand_size < 10: | ||
| letter = random.choice(list(letter_bank_keys)) |
There was a problem hiding this comment.
| letter = random.choice(list(letter_bank_keys)) | |
| letter = random.choice(list(letter_bank)) |
The default iterator over a dictionary is its keys so the keys() method can be removed and we'll experience the same result.
|
|
||
| def uses_available_letters(word, letter_bank): | ||
| pass | ||
| """ |
There was a problem hiding this comment.
👍 Good use of the count method!
| return True | ||
|
|
||
|
|
||
| def score_word(word): |
|
|
||
| # Checks len of word, if word is empty, and case of word | ||
| # in order to determine score | ||
| if len(word) in range(7, 11): |
There was a problem hiding this comment.
Clever use of range to describes word lengths between 7 and 10.
| letter_bank = { | ||
| "A": 9, | ||
| "B": 2, | ||
| "C": 2, | ||
| "D": 4, | ||
| "E": 12, | ||
| "F": 2, | ||
| "G": 3, | ||
| "H": 2, | ||
| "I": 9, | ||
| "J": 1, | ||
| "K": 1, | ||
| "L": 4, | ||
| "M": 2, | ||
| "N": 6, | ||
| "O": 8, | ||
| "P": 2, | ||
| "Q": 1, | ||
| "R": 6, | ||
| "S": 4, | ||
| "T": 6, | ||
| "U": 4, | ||
| "V": 2, | ||
| "W": 2, | ||
| "X": 1, | ||
| "Y": 2, | ||
| "Z": 1, | ||
| } |
There was a problem hiding this comment.
Long chunks of data like letter_bank tend to clutter functions and require more scrolling to see the rest of the function body. Consider moving this dictionary outside of this function (or in a new file) as a constant variable to be referenced in draw_letters.
| """ | ||
|
|
||
| # Initialize variables | ||
| score_tuples = [] |
There was a problem hiding this comment.
This variable is reassigned to a tuple later but it remains unclear as to why score_tuples starts off as a list data type.
To stay true to its name and for clear communication purposes, I recommend keeping a variable assigned to a specific data type.
| score_tuples = [] | |
| score_tuples = () |
There was a problem hiding this comment.
This is more of a python quirk, in statically typed languages like C#, assigning a variable to a different data type is NOT allowed (unless using some type of dynamic compiler).
| score_tuples = ((word, score_word(word))) | ||
|
|
||
| # If tied for high score | ||
| if score_word(word) == current_high_score: | ||
| if len(word) < winning_word_length and winning_word_length != 10: | ||
| score_tuples = ((word, score_word(word))) | ||
| winning_word_length = len(word) | ||
|
|
||
| # Length 10 edge case | ||
| elif len(word) == 10 and winning_word_length != 10: | ||
| score_tuples = ((word, score_word(word))) |
There was a problem hiding this comment.
The outer parenthesis is unnecessary.
| score_tuples = ((word, score_word(word))) | |
| # If tied for high score | |
| if score_word(word) == current_high_score: | |
| if len(word) < winning_word_length and winning_word_length != 10: | |
| score_tuples = ((word, score_word(word))) | |
| winning_word_length = len(word) | |
| # Length 10 edge case | |
| elif len(word) == 10 and winning_word_length != 10: | |
| score_tuples = ((word, score_word(word))) | |
| score_tuples = (word, score_word(word)) | |
| # If tied for high score | |
| if score_word(word) == current_high_score: | |
| if len(word) < winning_word_length and winning_word_length != 10: | |
| score_tuples = (word, score_word(word)) | |
| winning_word_length = len(word) | |
| # Length 10 edge case | |
| elif len(word) == 10 and winning_word_length != 10: | |
| score_tuples = (word, score_word(word)) |
| winning_word_length = len(word) | ||
|
|
||
| # return high score as tuple | ||
| return score_tuples |
There was a problem hiding this comment.
Other than my comment on data types and parenthesis, this function looks great. We can really get bogged down with too many nested conditionals in this scenario so I appreciate how neat this approach is!
| import random | ||
|
|
||
|
|
||
| def draw_letters(): |
| """ | ||
|
|
||
| # Created copy of letter_bank to leave original letter_bank unchanged | ||
| letter_bank_copy = letter_bank.copy() |
No description provided.