pythonindexerror_Python index错误值不在list…on.index(value)

我是Python的初学者,对于那些对我的帖子持负面看法的人,请离开。我只是在这里寻求帮助并努力学习。我试图在一个简单的数据集中检查0s和1s。这将用于在楼层平面上定义空洞和实体,以定义建筑中的分区。。。最终0和1将与坐标交换。

我收到此错误:ValueError:[0,3]不在列表中

我只是检查一个列表是否包含在另一个列表中。currentPosition's value is [0, 3]

subset, [[0, 3], [0, 4], [0, 5], [1, 3], [1, 4], [1, 5], [2, 1], [3, 1], [3, 4], [3, 5], [3, 6], [3, 7]]

下面是代码片段:def addRelationship(locale, subset):

subset = []; subSetCount = 0

for rowCount in range(0, len(locale)):

for columnCount in range (0, int(len(locale[rowCount])-1)):

height = len(locale)

width = int(len(locale[rowCount]))

currentPosition = [rowCount, columnCount]

currentVal = locale[rowCount][columnCount]

print "Current position is:" , currentPosition, "=", currentVal

if (currentVal==0 and subset.index(currentPosition)):

subset.append([rowCount,columnCount])

posToCheck = [rowCount, columnCount]

print "*********************************************Val 0 detected, sending coordinate to check : ", posToCheck

newPosForward = checkForward(posToCheck)

newPosBackward = checkBackward(posToCheck)

newPosUp = checkUpRow(posToCheck)

newPosDown = checkDwnRow(posToCheck)

我正在使用subset.index(currentPosition)检查[0,3]是否在子集中,但获取[0,3]不在列表中。怎么会?

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值