Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions python_pass.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,26 @@


class StringOperations:
def reverse(self, *, to_be_reversed: str = None):
raise NotImplemented('This method need to be implemented')
def reverse(self, to_be_reversed):

return reversed_string


# create a ReversedString class inherting from String operation class
class ReversedString(StringOperations):
def reverse(self, to_be_reversed):
# a copy from input named reversed_string
reversed_string = to_be_reversed

# reversing the copy by create a slice that starts with the length of the string, and ends at index 0
reversed_string = reversed_string[::-1]

# return a reversed copy
return reversed_string


# creat an Instantiate from ReversedString class
string_to_revers = ReversedString()

# print the output of the reverse function
print(string_to_revers.reverse("hello world "))