livepython.net

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.

Learn this firstChapter 17 · Python try, except, else and finally Explained
solution.py
# write your code here

EXPECTED OUTPUT

17 is odd

YOUR OUTPUT

Press Run to see your output here. Lines are compared with the expected output.