如何解决“值错误:不在列表中”错误?

时间:2019-07-30 01:33:32

标签: python

Olá,Python的sou iniciante,python的queria saber como fazer和cer der certo o meu的编程,python的sabendo que estou tentando的演示都可以使用list.util.ando .index()。

  

嗨,我是python的新手,我想知道如何制作python程序   工作,知道我要证明自己的立场   列表中的元素使用.index()。

lista=list()
a=30
b=40
c=50
d=60
lista .append([a,b],[c,d])
print(lista)
z=lista.index(b)
print(z) 

Espero asaída0,1,mas ocorre um erro值错误:列表中没有40

  

我等待输出0.1,但发生错误值错误:40不在   列表

1 个答案:

答案 0 :(得分:1)

您可以尝试list.extend

console.log(useEffect called)

您将获得以下输出:

lista=list()
a=30
b=40
c=50
d=60
lista.extend([a,b,c,d])
print(lista)
z=lista.index(b)
print(z) 
相关问题