7/23/2023 0 Comments Scrabble word generator finder![]() If you refactor these to function parameters, you can programatically change and reuse them (i.e. You're using a fair amount of hard coded constants and globals.Use a main function so you can import the code in this file: if _name_ = "_main_":ĭict = dict_maker(scores, word_master, rack) Note how this also simplifies the logic too since a function return acts more naturally than a break. I'd argue this helps with code readability since the function name documents what the inner for loop is doing while also allowing for code reuse. You could break out some of the code in rack_check into a seperate function perhaps called can_be_spelled. Since it kind of acts like a main function, this is somewhat excusable however, it's doing its own job (printing the tuples) while also having to call dict_maker. It would be much better to pass that user input as a parameter.Īnother function that does too much is list_print. For example dict_maker gets input from the user (not specified in docstring). Several of your functions are doing too much work. Furthermore, you can even replace for item in word_master: with for item in look_up() word_master = look_up() should be contained in rank_check function.This is fairly uncommon practice, as it shadows a builtin. In list_print you assigned a dictionary using dict as its name. ![]() I'm a little short on time to look over the logic, so I will finish the rest later, but here's some quick observations. The task was to create something that would provide a list of the best possible words to play given a set of letters on your rack. This is a project I saw online that I tried to tackle today. I'm very new to coding and am trying to work through projects for practical review of what I know, but I would like to be able to simplify/improve what I've made.
0 Comments
Leave a Reply. |