Python

self

자동매매 2026. 1. 29. 16:06
class AdvancedList(list):
    def replace(self, old, new):
        while old in self:
            self[self.index(old)] = new


x = AdvancedList([1, 2, 3, 1, 2, 3, 1, 2, 3])
x.replace(1, 100)
print(x)