Write a function with signature:
valid(text, chars="ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789")
The function should return a (possibly empty) string which is a copy of text
that only contains characters in chars. For example:
valid("Barking!") # Returns "B"
valid("KL754", "0123456789") # Returns "754"
valid("BEAN", "abcdefghijklmnopqrstuvwxyz") # Returns ""
It can be done in half a dozen lines, using a for loop and an if statement, not
counting the docstring, which should also be written.
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here