Quote:
Originally Posted by smoothrolla
Thanks Charley!
|
chaley, not charley.
Quote:
But this bit of that code adds tags in lowercase:
Code:
for item in l1lcase:
for item2 in l2:
if item2 in item:
res.add(item2)
break
|
That is the point of the 'enumerate'. The arrays l1 and l1lcase are ordered and indexed the same, so
Code:
for idx,item in enumerate(l1lcase):
for item2 in l2:
if item2 in item:
res.add(l1[idx])
break
will add the cased version of item2 to the result.
The enumerate operator returns the index and the value (a tuple in python terms), which in this case is the index and the lowercase version of the value. Because l1lcase and l1 are parallel arrays, the l1[idx] gets the equivalent item for the one in l1lcase, which is the cased version.