Queer European MD passionate about IT

adieu.py 576 B

12345678910111213141516171819202122232425
  1. def main():
  2. names = []
  3. while True:
  4. try:
  5. name = input("Name: ")
  6. names.append(name)
  7. except EOFError:
  8. break
  9. if len(names) == 0:
  10. return
  11. result = "Adieu, adieu, to "
  12. for n, name in enumerate(names):
  13. if n == 0:
  14. result += name
  15. elif n == 1 and len(names) == 2:
  16. result += f" and {name}"
  17. elif n == len(names) - 1:
  18. result += f", and {name}"
  19. else:
  20. result += f", {name}"
  21. print(result)
  22. if __name__ == "__main__":
  23. main()