>> if 'ar' or 'ko' in item: This is incorrect. What you meant to say was: if 'ar' in item or 'ko' in item: or something equivalent to that. "if 'ar' or 'ko' in item" means "if ('ar') is True or ('ko' in item) is True". Since 'ar' is True anyway, you'll get a match every time.