22 lines
488 B
Python
22 lines
488 B
Python
# Exercise 10-5 Guest Book
|
|
# Learning Objective: Save by appending to a file.
|
|
|
|
from pathlib import Path
|
|
|
|
path = Path('./Chapter_10/guest-book.txt')
|
|
|
|
current_guest = ""
|
|
|
|
guest_list = ""
|
|
|
|
actively_asking = True
|
|
while actively_asking:
|
|
current_guest = input("Enter a guest name, when done type (n/N):\n\t")
|
|
if current_guest.lower() != 'n':
|
|
guest_list += current_guest + "\n"
|
|
else:
|
|
actively_asking = False
|
|
path.write_text(guest_list)
|
|
print("Guest book updated")
|
|
|