python的NameError: name index is not defined该怎么解决?

python的NameError: name index is not defined该怎么解决?

问题描述:

lst=['hello','景大佩',98,'hello']
print(lst,index('hello'))
所写程序如上,但是出现报错:
print(lst,index('hello'))
NameError: name 'index' is not defined。
请问怎么解决?

lst后面应该是 . 点你写成逗号了

lst=['hello','景大佩',98,'hello']
print(lst.index('hello'))

img