From b697cfcd66cb484f3e9ddd98ce506e2b2a6495d9 Mon Sep 17 00:00:00 2001 From: baphim <269010393+baphim@users.noreply.github.com> Date: Sun, 13 Sep 2026 16:46:04 -0400 Subject: [PATCH] feat: completed problem-07.py --- lab-02/problem-07.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/lab-02/problem-07.py b/lab-02/problem-07.py index 8a3b006..da6a000 100644 --- a/lab-02/problem-07.py +++ b/lab-02/problem-07.py @@ -1,2 +1,10 @@ # Write a Python program that prompts the user to input a number and handles a KeyboardInterrupt exception if the user -# cancels the input. \ No newline at end of file +# cancels the input. + +# Prompt user to input a number and try if the input is cancelled +try: + input('Enter a number: ') +# Handle the expected KeyboardInterrupt exception +except KeyboardInterrupt: + # Print termination message + print('Program terminated by user.') \ No newline at end of file