how to break loop with keypress ("Y"):
I want to stop function by pressing key "Y", not CTRL+C.
Here's my code:
def main():
while True:
try:
num = int(input("Enter a number: "))
if (num % 2) == 0:
print("Even number")
elif (num % 2) != 0:
print("Odd number")
except (ValueError, Exception):
print("Inappropriate number")
if __name__ == "__main__":
main()