Conversation
apradoada
left a comment
There was a problem hiding this comment.
Well done, Anees! This project scores a GREEN!
Overall your code looks great and it passes all the tests! I just left a few comments here and there for you to think about, but really nothing that you need to correct unless you would like to! Well done and congratulations on finishing your first project!
| def draw_letters(): | ||
| pass | ||
| # array_of_strings = [ ] | ||
| LETTER_POOL = { |
There was a problem hiding this comment.
This is a great dictionary to hold the letters and the count of each letter! When creating it, you've followed the naming convention of a global variable which I agree would be the best way to hold this information just in case we need to use this dictionary elsewhere! The one change I would make here would be to move it outside this function which is what we would do to make sure the dictionary is available to the other functions that might need it. If we have several pieces of this kind of information, it is also possible to put your data in a separate file and import it in as well!
| } | ||
|
|
||
| letter_pool = [] | ||
| for letter, count in LETTER_POOL.items(): |
There was a problem hiding this comment.
I love this way of creating a list to hold every letter while still taking into account the distribution! It's short and concise and works well! Great use of the extend methond!
| for _ in range(10): | ||
| random_index = random.randint(0, len(letter_pool) - 1) | ||
| hand.append(letter_pool[random_index]) | ||
| letter_pool.pop(random_index) |
There was a problem hiding this comment.
This for loop is once again concise and well constructed! Great use of the pop method as well. The only consideration I would add is that the pop method does run in O(n) time. If you'd like an extra challenge, see if you can write this in a way that doesn't use the pop method and runs in O(1) time! Note: That code will be a little more involved but it will decrease the complexity.
| letter_bank_remaining.remove(letter) | ||
| else: | ||
| return False | ||
| return True |
There was a problem hiding this comment.
Love this function! It's easy to read, well written and concise! No notes!
| pass | ||
|
|
||
| # Define the letter scores | ||
| score_chart = { |
There was a problem hiding this comment.
If we were going to expand on this project, this dictionary would be a great candidate for global variable status!
|
|
||
| # Sum up the score for each letter | ||
| for letter in word: | ||
| total_score += score_chart.get(letter, 0) # Add 0 if letter is not found (for safety) |
| total_score += score_chart.get(letter, 0) # Add 0 if letter is not found (for safety) | ||
|
|
||
| # Add bonus points if the word is 7-10 letters long | ||
| if 7 <= len(word) <= 10: |
There was a problem hiding this comment.
Great use of this notation for a range based conditional!
| current_score = score_word(word) | ||
|
|
||
| # Update best_word and best_score if conditions are met | ||
| if ( |
There was a problem hiding this comment.
I love that you handled all of the logic as each word gets scored! I also commend you for taking care of all the logic in one long compound conditional! That being said, I would argue that this is one case where nested conditionals will make the code a little more readable. It will also cut down on some of the conditionals you have to parse through!
No description provided.