Skip to content

Ada-C8/string_reverse_python

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 

Repository files navigation

String Reverse in Python

In this assignment, you'll design and implement one of the string manipulation functions that is commonly asked during interviews.

Exercise

Design and implement a method to reverse a string. For example, if the method is called with an input parameter of "Lovelace", the method should return a new string object with the value "ecalevoL". Share and explain the time and space complexities for your solution.

Python Considerations

The Ruby version of this assignment involved reversing a string in place. Unlike Ruby strings, Python strings are immutable, which means they can't be changed after they are initialized. Because strings cannot be modified in place, a new string must be created whenever a change must be made to a string.

Note: Do not use Python provided functionality for reversed(), reverse(), or string slicing ("string"[::-1]). You may use len().

Running the Tests

Install pytest

pip install pytest

To run all tests, navigate to the same directory as the test file and run:

pytest test_string_reverse.py

Alternatively, to exit instantly on first error or failed test, run:

pytest -x test_string_reverse.py

See pytest documentation for more information about pytest.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%