Validate an int input using try except (Python) Input Format Input could be characters or numbers. Constraints Exact prompt text each time input is requested must be "Please enter a whole number: " When a whole number is not provided, output "That was not a valid number. Please try again." You MUST use try except. Even if all test cases pass, your code will be checked and you will not get credit if you don't use try except. When a whole number is entered, output "Valid". Output Format Please enter a number: That was not a valid number. Please try again. Valid Sample Input 0 one pi googol 0.12345678910111213 42 Sample Output 0 Please enter a number: That was not a valid number. Please try again. Please enter a number: That was not a valid number. Please try again. Please enter a number: That was not a valid number. Please try again. Please enter a number: That was not a valid number. Please try again. Please enter a number: Valid

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter6: User-defined Functions
Section: Chapter Questions
Problem 8PE
icon
Related questions
Question

Validate an int input using try except (Python)

Input Format

Input could be characters or numbers.

Constraints

Exact prompt text each time input is requested must be "Please enter a whole number: "
When a whole number is not provided, output "That was not a valid number. Please try again."
You MUST use try except. Even if all test cases pass, your code will be checked and you will not get credit if you don't use try except.
When a whole number is entered, output "Valid".

Output Format

Please enter a number:
That was not a valid number. Please try again.
Valid

Sample Input 0

one
pi
googol
0.12345678910111213
42

Sample Output 0

Please enter a number: That was not a valid number. Please try again. Please enter a number: That was not a valid number. Please try again. Please enter a number: That was not a valid number. Please try again. Please enter a number: That was not a valid number. Please try again. Please enter a number: Valid
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 6 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT