Whales - Alexa Coffman and Uyen Vong#36
Conversation
goeunpark
left a comment
There was a problem hiding this comment.
Wonderful work, Alexa and Uyen! 🚀
Your tests pass, your logic is superb, and I can wax poetic about your spiffy update_best_word function all day long. Y'all have made great choices regarding your data types and your code is exceptionally clean and efficient. This project is a Green. 🟢
Let me know if you have any questions on the feedback. Keep it up!
| while len(drawn_letters) < 10: | ||
| rand_index = randint(0, len(letter_pool_copy)-1) | ||
| drawn_letters.append(letter_pool_copy.pop(rand_index)) |
There was a problem hiding this comment.
Interesting way to randomly pick a letter! I also love that you modeled your LETTER_POOL list to contain the correct frequency of letters in a bag. Great work!
There was a problem hiding this comment.
But also...what if the instructors were feeling ~ chaotic ~ and said there were 100,000 tiles in the pool in total? Could you have programmatically made the LETTER_POOL list? (I'm sure you could have!)
| # create a copy of letter bank so we don't alter original list | ||
| letter_bank_copy = deepcopy(letter_bank) | ||
| word = word.upper() | ||
| valid_word = True |
There was a problem hiding this comment.
This is soooo pythonic! 🐍 I adore how y'all set a boolean for valid_word at the top of the function and reassign on L56 depending on the condition, then return this boolean only once in L60! While the following is acceptable:
if [valid conditional]:
return True
else:
return False
What y'all did (set a boolean variable to have only one return statement at the end of the function, like below) is a Pythonista's dream! Great work!
valid = True
if [not valid conditional]:
valid = False
return valid
| if word == None: | ||
| return None |
| best_word = { | ||
| "word" : "", | ||
| "score" : 0 | ||
| } |
There was a problem hiding this comment.
Love the organization of best word and score as a dictionary! 🤩
| def update_best_word(best_word, word, score): | ||
| best_word["score"] = score | ||
| best_word["word"] = word |
| def update_best_word(best_word, word, score): | ||
| best_word["score"] = score | ||
| best_word["word"] = word | ||
| return best_word No newline at end of file |
There was a problem hiding this comment.
Python (and most languages, if I think of it) likes it when you have a newline at the end of the file. (Why? Because it's one of those Just Unix/Computer Things, I guess?)
No description provided.