在PYTHON ...如何在NESTED元组

时间:2017-07-05 17:18:58

标签: indexing nested tuples partial

这是我的嵌套元组列表...这意味着,每个元组在每个元组中包含另外两组元组。

 R22 =   [((13, 15, 1), (3, 8, 1)), ((13, 16, 1), (3, 11, 1)), ((13, 27, 1), (3, 32, 1)), ((13, 36, 1), (3, 44, 1)), ((13, 47, 1), (3, 46, 1)), ((15, 16, 1), (8, 11, 1)), ((15, 27, 1), (8, 32, 1)), ((15, 36, 1), (8, 44, 1)), ((15, 47, 1), (8, 46, 1)), ((16, 27, 1), (11, 32, 1)), ((16, 36, 1), (11, 44, 1)), ((16, 47, 1), (11, 46, 1)), ((27, 36, 1), (32, 44, 1)), ((27, 47, 1), (32, 46, 1)), ((36, 47, 1), (44, 46, 1))]

现在我需要找到部分元素的索引,例如

FindeIndex('13, 15') and the expected result would be 0,0 and for (3, 11) the answer would be 1,1. and for (3,8) the expected answer would be 0,1. and so on.

PS:请注意我并没有试图找到整个元组的索引,我只在NESTED元组中使用前两个PARTIAL元素。

And what i tried is 

    print(R22.index('(13, 27)')) is not working and saying can't find in list.

    and i tried this way print(R22.index('(13, 27, 1), (3, 32, 1)')) also said not found.

0 个答案:

没有答案