We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents bcba0a5 + e59516c commit 73344d1Copy full SHA for 73344d1
superstring/superstring.py
@@ -73,9 +73,10 @@ def __str__(self):
73
return self.toPrintable()
74
75
def __getitem__(self, key):
76
- # TODO: Negative Indexing
77
if isinstance(key, slice):
78
- return self.substring(key.start, endIndex = key.stop)
+ start = key.start if key.start > 0 else self.length() + key.start
+ stop = key.stop if key.stop > 0 else self.length() + key.stop
79
+ return self.substring(start, end_index=stop)
80
return self.characterAt(key)
81
82
class SuperString(SuperStringBase):
0 commit comments