Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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.
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started