12345678910111213141516171819202122232425 |
- def main():
- names = []
- while True:
- try:
- name = input("Name: ")
- names.append(name)
- except EOFError:
- break
- if len(names) == 0:
- return
- result = "Adieu, adieu, to "
- for n, name in enumerate(names):
- if n == 0:
- result += name
- elif n == 1 and len(names) == 2:
- result += f" and {name}"
- elif n == len(names) - 1:
- result += f", and {name}"
- else:
- result += f", {name}"
- print(result)
- if __name__ == "__main__":
- main()
|