154. Python Program to Check Even or Odd with try, except and else
Easyelse and finally
Overview
Keep the try small, and put the next steps in else.
Problem Statement
Read a whole number. If it is even, print it followed by is even; if it is odd, print it followed by is odd. For example, for 7:
7 is odd
If the input is not a whole number, print:
Not a whole number
Use input() with no prompt text: the tests type the input for you, and a prompt would end up in your output.
Input
One value. Example:
7
Output
The output for that example:
7 is odd
The tests try 5 different inputs.