From b5e95f55f6706abc3ffcd754845b3a0f8aaea4c0 Mon Sep 17 00:00:00 2001 From: cheeks <134818917+leftovertoast@users.noreply.github.com> Date: Mon, 3 Mar 2025 18:18:56 +0000 Subject: [PATCH] Completed 10-4 Guest --- Chapter_10/10-04_guest.py | 11 +++++++++++ Chapter_10/guest.txt | 1 + 2 files changed, 12 insertions(+) create mode 100644 Chapter_10/10-04_guest.py create mode 100644 Chapter_10/guest.txt diff --git a/Chapter_10/10-04_guest.py b/Chapter_10/10-04_guest.py new file mode 100644 index 0000000..4a795fb --- /dev/null +++ b/Chapter_10/10-04_guest.py @@ -0,0 +1,11 @@ +# Exercise 10-4 Guest +# Learning objective: Save information to a text file. + +from pathlib import Path + +guest_name = "" +guest_name = input("Welcome guest, what is your name?\n") + +path = Path('./Chapter_10/guest.txt') +path.write_text(guest_name) +print(f"Thanks and Welcome {guest_name}, your name has been recorded in guest.txt.") diff --git a/Chapter_10/guest.txt b/Chapter_10/guest.txt new file mode 100644 index 0000000..fb1f346 --- /dev/null +++ b/Chapter_10/guest.txt @@ -0,0 +1 @@ +Beans \ No newline at end of file