Mar-11-2021, 07:57 PM
I would use a sentinel value (None, if that's not valid) to mark a Not Found case. So for this:
def lookup(first_name, middle_name, surname): if first_name == 'alex': return 1 if middle_name == 'larry': return 2 if middle_name == 'mark': return 3 if first_name == 'sarah': return 4 if surname == 'smith': return 5 return None if (res := lookup(f, m, s)) is None: # not found