I want my loop to return true if any element of positions match with the string. First, i split to find the position needed. positions = ['founder','cto','partner'] and string is person_title = "director and cto at company"
My code:
def check_title(person_title,positions):
person_titles = person_title.split(" ")
for one_title in person_titles:
for one_position_check in positions:
if one_position_check == one_title :
answer = True
else:
answer = False
return answer
The answer should be True but I am getting False. Any help?
return Trueas soon as you find a match.