Question: def before _ space ( s ) : Returns the substring of s up to , but not including, the first space.

def before_space(s):
"""
Returns the substring of s up to, but not including, the first space.
Example: before_space('Hello 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 before_space, paying close attention to the precondition. Create test cases for this function and add them to the test procedure test_before_space 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 assert_equals in introcs.
See the Unit Test Functions in the IntroCS API for more information.
When designing test cases for before_space, 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 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 Programming Questions!