Question: def before _ space ( s ) : Returns the substring of s up to , but not including, the first space.
def beforespaces:
Returns the substring of s up to but not including, the first space.
Example: beforespaceHello World' returns 'Hello'
Parameter s: the string to slice
Precondition: s is a string with at least one space in it
Reread the specification for beforespace, paying close attention to the precondition. Create test cases for this function and add them to the test procedure testbeforespace in testcurrency.py Remember, to implement a test case:
Call the function on a sample input of your choice.
Store the returned result as a variable.
Compare the result with the expected output using assertequals in introcs.
See the Unit Test Functions in the IntroCS API for more information.
When designing test cases for beforespace, think about how spaces may occur in the string both position and frequency and how that can affect the result.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
