Skip to content

Commit 061adac

Browse files
committed
TR updates, first round
1 parent ef22b53 commit 061adac

File tree

2 files changed

+7
-2
lines changed

2 files changed

+7
-2
lines changed

inherit-python-string/lower_string.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ def __init__(self, string):
88
# instance = super().__new__(cls, string.lower())
99
# return instance
1010

11+
1112
# from collections import UserString
1213

1314

inherit-python-string/mutable_string.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,14 @@
33

44
class MutableString(UserString):
55
def __setitem__(self, index, value):
6-
self.data = self.data.replace(self.data[index], value)
6+
data_as_list = list(self.data)
7+
data_as_list[index] = value
8+
self.data = "".join(data_as_list)
79

810
def __delitem__(self, index):
9-
self.data = self.data[: index - 1] + self.data[index:]
11+
data_as_list = list(self.data)
12+
del data_as_list[index]
13+
self.data = "".join(data_as_list)
1014

1115
def upper(self):
1216
self.data = self.data.upper()

0 commit comments

Comments
 (0)