Question: PYTHON : Two short codes 1. Input validation - Get a string from the user. Validate that the string length is between 2 and 5.

PYTHON: Two short codes

1. Input validation - Get a string from the user. Validate that the string length is between 2 and 5. if not, let the user know and ask them again. Keep asking until you get a valid string. Once you get a valid string, exit the loop and print "Success. We got ". (Hint: Use the while loop, len function, if statement)

2. Input validation with error checking - Get a valid integer from the user between 3 and 9 and print it. Note that if the user enters a string, the code will throw an error when you try to cast it, that you will have to catch. If the user enters an invalid integer, let them know and ask again. Keep asking until you get a valid integer between 3 and 9. (Hint: You will use the while loop, casting, try/except, if statement)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!