Completed 10-5 Guest Book

This commit is contained in:
cheeks 2025-03-03 18:33:44 +00:00
parent b5e95f55f6
commit c83a21a61a
2 changed files with 28 additions and 0 deletions

View File

@ -0,0 +1,21 @@
# 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")

View File

@ -0,0 +1,7 @@
James
Jimmy
David
Dan
Henry
Izakura
Paul