为什么我的程序导致IDLE崩溃?

时间:2015-06-05 09:49:01

标签: python crash append permutation python-idle

我正在尝试创建一个程序,该程序从用户那里获取一个扰乱的单词,然后将其与列表进行比较并查找相似的单词,然后显示用户可能的单词匹配。

然而,每当我运行该程序时,它都会崩溃IDLE。所以我的问题是为什么它会崩溃IDLE?

def anagrams(s):
    if s =="":
        return [s]
    else:
        ans = []
        for u in anagrams(s[1:]):
            for pos in range(len(u)+1):
                ans.append(u[:pos]+s[0]+u[pos:])
            return ans


def unscramble(x):
    clean_unscram = []
    word1 = open(x, 'r')
    word2 = word1.read()
    word3 = word2.lower()
    word4 = word3.split()
    scrambled = anagrams(input('Pease enter a jumbled word:'))
    #everything below this line is for sorting the words and then adding it to the clean_unscram(bled) list
    for anagram in scrambled:
        if anagram in word4:
            for anagram in word4:
                if anagram not in clean_unscram:
                    clean_unscram.append(word4)
                    break
                    return clean_unscram

0 个答案:

没有答案