I have some problem with one task (only this task left from 12 tasks). I am trying to write a scrabble code on python.
I have to write a function that gets all the possible words from the given letters in hand. And there is an asterisk that can be replaced by any letter.
For example:
Given letters = 'crn*'
Words can be = 'cry', 'corn' and etc. I can't get all the possible words when there is an asterisk....
User Profile
Collapse
-
How to get possible words from the given letters?
-
How to check if the element is contained in list or not?
Hello,
I have some problem with checking if the element is contained in the list or not.
For example:
a = ['abc', 'def', 'gh', 'i']
b = 'abc'
Following is my code:
Is it correct?Code:def is_proper_word(b, a) : is_proper = False for b in proper_word_list: is_proper = True return is_proper
... -
Hello!
I am doing my homework and trying to get possible words from given letters.
For example:
Here is your hand: AONEP
Enter your word: ?
(POPPA, 11)
(NAPPE, 9)
(NAPPA, 9)
(POPE, 8)
(POOP, 8)
(PEPO, 8)
(PEEP, 8)
(PAPA, 8)
It must use p only once, but here is more that one. Can you please help me to find my mistake. Following is my... -
Is there any other way to do it? Because we can't use any set command in our homework.
Thank you....Leave a comment:
-
Thank you for your kind attention to my question. Yes, I am doing my python homework. I have a question about how to check if every element in one list is contained in the another list. For example:
a = ['a', 'b', 'c'] and b = ['c', 'a']...Leave a comment:
-
How to get possible words from the given letters?
Hello,
I am writing a "scrabble code" on Python. I have some problem with getting possible words from the given letters. For example:
Given letters are: 'c', 'r', 'n', '*'
Here '*' can be any letter.
Possible words: 'cry', 'corn', 'run', etc.
proper_word_lis t is a file containing all the english words.
score_of_word is a function that computes the score of the word.
hand is the... -
-
How to convert a string into list of strings
Hello,
I am trying to convert a string into list of strings.
The output is like the following:
[['a', 'a'], ['b'], ['c']].
However, the output must be like:
['a', 'a', 'b', 'c']
My code is like the following:
...Code:return_letter = "" letter_list = [] f = open(file_name,"r") for line in f: k = line[:1] letter_list.append(k.split()*int(line[1:]))
No activity results to display
Show More
Leave a comment: