I have two list.
The first list contains languages and contains about 30000
items.
['es','de', 'ita', ....]
The second list contains about twenty language codes, as follow :
['eng', 'ar', 'fr', 'ch', 'jp', 'ita' .... ]
What I want to do is to search and see if the 1
st book is related to the code 19
( 1 is the index of the book in the first list) and if found, print the code index from the second list
import csv
book_language_list = []
with open('language_table_for_search.csv', 'r') as rf:
reader = csv.reader(rf, delimiter=',')
for row in reader:
book_language_list.append(row[2])
book_language_distinc = []
with open('language_codes.csv', 'r') as rf:
reader = csv.reader(rf, delimiter=',')
for row in reader:
book_language_distinc.append(row[1])
for i in range(0, len(book_language_list)):
if any(book_language_list[i] in s for s in book_language_distinc):
# print the book id=i has language=(found language index)
for lang in book_language_list
and then get the index against the other list, as the ansewr below suggests. No need to do an indexed loop.