In my problem there are:
data_list=["Peter", "Alfred", "John", "Mark", "Paul", "Michael"]
data_list is a list that contains some data, for example names.
list_data_index=[["A", "2"], ["B", "5"], ["C", "0"]]
list_data_index is a list of lists in which each list contains the data that has to be compared with data stored into data_list (e.g. A), and the index in which the data is stored into data_list (e.g. 2)
For example, list_data_index[0]=["A", "2"] means that A has to be compared with data_list[2].
The problem is that list_data_index has an unknown length, and this makes complex to implement the if statement.
since I don't know the length of list_data_index, I cannot do:
if list_data_index[0][0] == data_list[list_data_index[0][1]] and list_data_index[1][0] == data_list[list_data_index[1][1]] and list_data_index[2][0] == data_list[list_data_index[2][1]]:
#do-something
else:
pass
I have already raised a similar problem here but in the linked case I was working with only one lists of list. In the case of this question, I use to different lists, list_data_index and data_list, respectively.
How may I solve this problem?
Thanks.
Aucun commentaire:
Enregistrer un commentaire