

InterviewSolution
Saved Bookmarks
1. |
Solve : Input validation? |
Answer» Hi, Hi,input, AFAIK, can mean the input arguments to a function/procedure or the script arguments, or user input. To validate means to check them according to your predefined set of "rules". For example to get the user to key in a number (because you wanted them to) when they run your script, you can use the raw_input() and isdigit() function like this CODE: [Select]userinput = raw_input("Please ENTER a number: " ) if userinput.isdigit(): # <-- this is considered a validation. print "You entered a number, good" else: ...blah... The above example stores what the user keys in into variable userinput. Then the isdigit() method checks whether its a digit. This is called validation. Its the same for other types of inputs. Thank you so much Ghostdog74, That has helped alot. |
|