Python cheating at the game Scrabble

Write a program to cheat at the game Scrabble. The user enters a string. Your program should return a list of all the words that can be created from those seven letters.


wordlist = [line.strip() for line in open('C:/Users/ZM/Desktop/Documents/New folder/wordlist.txt')]
user_word =
input('Enter word: ')
d = {}
d1 = {}
c =
0
for i in user_word:
   
if i in d1:
        d1[i] +=
1
   
else:
        d1[i] =
1
print(user_word)
for i in wordlist:
   
for j in i:
       
if j in d:
            d[j] +=
1
       
else:
            d[j] =
1
   
if d == d1:
       
print(i)
    d = {}

SOLUTION:
   
Enter word: drapes

drapes
padres
parsed
rasped
spader
spared
spread

Коментари

Популарни постови са овог блога

Python Fan functions

Python StopWatch milliseconds

Python Accounting