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...



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.



May 26, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here