我正在编写一些代码来查看打印出我可以用字母字符串“myLetters”组成的单词列表,但由于某种原因,我的格式不起作用。它应该以单词列表的形式出现,其中空格数与 myLetters + 4 的长度一样多
def scrabbleWords(myLetters):
letterPoints = {'a':1,'b':3,'c':3,'d':2, 'e':1,'f':4,'g':2,'h':4,\
'i':1,'j':8,'k':5,'l':1,'m':3,'n':1,'o':1,'p':3,'q':10,'r':1,'s':1,\
't':1,'u':1,'v':4,'w':4,'x':8,'y':4}
wordList = createWordList('wordlist.txt')
myWords = []
for myWord in wordList:
x = canWeMakeIt(myWord,myLetters)
if x == True:
myWords.append(myWord)
pointWordList = []
for myWord in myWords:
t = getWordPoints(myWord,letterPoints)
pointWordList.append((t,myWord))
pointWordList.sort(reverse=True)
lenx = str(len(myLetters)+4)
for pointValue, myWord in pointWordList:
x = '{:'+lenx+'}{}'.format(myWord,pointValue)
print(x)