10 lines
390 B
Python
10 lines
390 B
Python
# Write a Python program that prompts the user to input a number and handles a KeyboardInterrupt exception if the user
|
|
# 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.') |