I have a binary string from a stdout in the form of b'This is ___ \n'
where the blank can a selection of fixed words, say ['apple', 'orange', 'pie']
. I want to assert whether the keyboard match my intended keyboard. One way I can:
s = b'This is Apple \n'
def check(s, correct_answer):
if correct_answer in str(s).lower():
return True
else:
return False
check(s, 'apple')
What would be the regex way to solve this? I know the keyword can only be one of the 3.