Queer European MD passionate about IT

deep.py 890 B

12345678910111213141516171819202122232425262728
  1. import re
  2. answer_regex = re.compile(r"\s*(42|forty[ -]?two)\s*", re.IGNORECASE)
  3. def ifelse_answer():
  4. answer = input("What is the Answer to the Great Question of Life, the Universe, and Everything?\t\t")
  5. answer = answer.strip()
  6. answer = answer.replace('-', '')
  7. answer = answer.replace(' ', '')
  8. answer = answer.lower()
  9. if answer in ('42', 'fortytwo'):
  10. print("Yes")
  11. else:
  12. print("No")
  13. def regex_answer():
  14. print('Yes'
  15. if answer_regex.match(
  16. input("What is the Answer to the Great Question of Life, the Universe, and Everything?\t\t"))
  17. else 'No')
  18. def oneliner():
  19. 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')])
  20. if __name__ == "__main__":
  21. regex_answer()