I have a list of tuple. I want to check if both the tuple elements are present in a string.
I came up with this code.
def check_if_present(user_name):
is_present = False
tuple_list = [('firstname1', 'secondname1'), ('firstname2', 'secondname2'), ('firstname3', 'secondname3')]
for user, name in tuple_list:
if user in user_name and name in user_name:
is_present = True
return is_present
check_if_present('firstname1 secondname2 test1') should return False and
check_if_present('firstname1 secondname1 test4') should return True
How can I reduce the lines of code to achieve the same logic? Or How can I achieve it efficiently?