Here is a function that is supposed to return True if word (any string) ends with "s" and False otherwise: def ends_with_s(word): if len(word) < 1: return False     return word[-1] == "s" Here is the test function I am using to test ends_with_s: def test_ends_with_s():     assert(ends_with_s("cats")) # option 1     assert(ends_with_s("") is False) # option 2     assert(ends_with_s("apple") is False) # option 3     assert(ends_with_s("S")) # option 4   Rewrite ends_with_s so that the test

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter15: Recursion
Section: Chapter Questions
Problem 6PE
icon
Related questions
Question

Here is a function that is supposed to return True if word (any string) ends with "s" and False otherwise:

def ends_with_s(word):
if len(word) < 1:
return False
    return word[-1] == "s"

Here is the test function I am using to test ends_with_s:

def test_ends_with_s():
    assert(ends_with_s("cats")) # option 1
    assert(ends_with_s("") is False) # option 2
    assert(ends_with_s("apple") is False) # option 3
    assert(ends_with_s("S")) # option 4
 
Rewrite ends_with_s so that the test passes 
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 2 images

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT