Python名称错误:名称'';没有定义

Python名称错误:名称'';没有定义,python,Python,我正在将简单代码输入IDLE,但在我运行简单程序后,它一直告诉我一个单词来检查有多少元音没有定义 def search4vowels(word): '''Return a boolean bassed on any vowels found.''' vowels = set('aeiou') return vowels.intersection(set(word)) 错误消息 Traceback (most recent call last): File &qu

我正在将简单代码输入IDLE,但在我运行简单程序后,它一直告诉我一个单词来检查有多少元音没有定义

def search4vowels(word):
    '''Return a boolean bassed on any vowels found.'''
    vowels = set('aeiou')
    return vowels.intersection(set(word))
错误消息

Traceback (most recent call last):
    File "<pyshell#11>", line 1, in <module>
        gal
    NameError: name '' is not defined
回溯(最近一次呼叫最后一次):
文件“”,第1行,在
女孩
NameError:未定义名称“”

我想您可以这样调用函数:
search4元音(gal)

试着这样称呼它:
search4元音(“gal”)

您必须将字符串括在引号中,否则python将查找名为
gal
(在您的示例中)的变量。
gal
未定义==>Error

您能修复缩进吗?而且您没有包括所有的代码
gal
不在您给出的代码中。该错误显然不是来自您发布的代码。当我运行代码并在>>>上输入一个单词,如“galaxy”“hitchhiker”等时,它会说“galaxy”或“ga”未定义,但这对defI来说是无效的语法,表示调用。不是函数定义。