I have two files, "ranked.txt" and "sorted.txt". Sorted.txt is a smaller subset from ranked.txt that is sorted in alpha order. However ranked.txt preserves the ranking of words I would like to keep.
How do I check the rank of every word in sorted.txt when matched to the original ranked.txt? I want to output the rank (which is the line number) from ranked.txt into sorted.txt.
This is what I have so far:
for word in sorted_list: for num, line in enumerate(ranked_list, 1): if word in line: print word, '\t', num
But this doesn't do exactly what I want... anyone help?