Question: Please have detailed explanations beside each code. Thank you. Occasionally, we might want to restrict what characters a person can enter into a program--for instance,

Please have detailed explanations beside each code. Thank you.Please have detailed explanations beside each code. Thank you. Occasionally, we might

Occasionally, we might want to restrict what characters a person can enter into a program--for instance, file names cannot contain / on Unix systems (as these are used to separate paths), and many websites will not allow you to put spaces in your passwords. Write a program that, given a string, s, and a single character, c, determines if the string is valid (that is, string s does not contain the exact character c). Your program should return False if c is in s , and True otherwise. In [ ]: def prohibitedCharacter(s, c): # Your code here. return ans In [ ]: # Your Provided Sample Test Cases print("#1", prohibitedCharacter('I\'d like to teach the world to sing!', 'T') == True) #notice it is case sensitive print("#2", prohibitedCharacter( 'www.cas.mcmaster.ca', '$') == True) print("#3", prohibitedCharacter('tom_cruise! @mcmaster.ca', '!') == false)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!