Substring Index Python Find Duplicates