I would like to return random word from file, based on passed argument. But if the argument doesn't match anythning I dont want to return anything. My method looks like:
def word_from_score(self,score):print(random.choices([word for word in self.file if sum([LETTER_SCORES[letter] for letter in word ]) == score]))
It returns the correct word from file based on passed argument in command line, but if the argument doesnt match, i want to return nothing, like ''. How could I add else to this statement?