prompt.py 322 B

12345678910111213141516171819
  1. import sys
  2. def yes_no(msg: str):
  3. sys.stdout.write(f"{msg} <Y/n>")
  4. choice = input()
  5. if choice in {'Y','y',''}:
  6. return True
  7. elif choice in {'N','n'}:
  8. return False
  9. else:
  10. print("Please respond with 'y' or 'n'")
  11. return yes_no(msg)
  12. def pause():
  13. print("press any key...")
  14. input()