feat: completed problem-07.py
This commit is contained in:
@@ -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.
|
||||
# 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.')
|
||||
Reference in New Issue
Block a user