-
Book Overview & Buying
-
Table Of Contents
MySQL for Python
By :
Just because user input is not valid, it does not mean we should scrap it and ask the user for a new input. Rather, we can accept an entire statement, assign what values will fit and come back to the user to correct data that will not.
To do this, we need to import the string module and define three functions to do the following:
Validate the name column.
Validate the price column.
Query the user for a correction.
After defining the functions, we pass the user values to the first two functions, we then pass the user values in turn to the first two functions which then calls the third function only if the data does not check out.
Simply append string to the import line for the program or add the following line below it:
import string
Now, let's define the three functions.
This function needs to do the following:
Receive the value of the name column.
Check whether it is all letters—for example, no fish has numbers in its market name.
Call...
Change the font size
Change margin width
Change background colour