Python joke program Functions in admin.py The requirements above mentioned 3 functions - input_int(), input_something(), and save_data().
Question:
Python joke program
Functions in admin.py The requirements above mentioned 3 functions - input_int(), input_something(), and save_data(). As part of admin.py, you must define and use these functions. 1. The input_int() function takes 1 parameter named prompt. The function should repeatedly re-prompt the user (using the prompt parameter) for input until they enter an integer of 0 or more (i.e. minimum of 0). It should then return the value as an integer. See Workshop 4 for a task involving the creation of a very similar function. 2. The input_something() function takes 1 parameter named prompt. The function should repeatedly re-prompt the user (using the prompt parameter) for input until they enter a value which consists of at least 1 non-whitespace character (i.e. the input cannot be nothing or consist entirely of spaces, tabs, etc.). It should then return the value as a string. Use the strip() string method on a string to remove whitespace from the start and end. If a string consists entirely of whitespace, it will have nothing left once you strip the whitespace away. Note that exception handling is not needed in this function. 3. The save_data() function takes 1 parameter named data_list (the data list from the main program). The function should open data.txt in write mode, then write the data_list parameter to the file in JSON format and close the file. This function does not return anything. This is the only part of the program that should be writing to the file, and it always overwrites the entire content of the file with the entirety of the current data. See Reading 7.1 for an example of using the json module. You can specify an additional indent parameter in the dump() function to format the JSON data nicely in the text file.