29 lines
890 B
Python

import re
answer_regex = re.compile(r"\s*(42|forty[ -]?two)\s*", re.IGNORECASE)
def ifelse_answer():
answer = input("What is the Answer to the Great Question of Life, the Universe, and Everything?\t\t")
answer = answer.strip()
answer = answer.replace('-', '')
answer = answer.replace(' ', '')
answer = answer.lower()
if answer in ('42', 'fortytwo'):
print("Yes")
else:
print("No")
def regex_answer():
print('Yes'
if answer_regex.match(
input("What is the Answer to the Great Question of Life, the Universe, and Everything?\t\t"))
else 'No')
def oneliner():
print({True: 'Yes', False: 'No'}[input("What is the Answer to the Great Question of Life, the Universe, and Everything?\t\t").lower().strip() in ('42', 'fortytwo', 'forty two', 'forty-two')])
if __name__ == "__main__":
regex_answer()