import copy
class TOTO:
def __init__(self, tipp1, tipp2):
self.tipp1 = tipp1
self.tipp2 = tipp2
self.column_n = 0
def value_exchange1(self):
"""A tipp1 lista elemeit 0 indextől kezdődően
lecseréli a tipp2 lista nem nullás elemeivel.
Minden egyes elem csere új tippsort hoz létre."""
i = 0
self.column_n = 0
while i < len(self.tipp1):
# Ha nem '0' az elem
if self.tipp2[i] != "0":
# A tipp1 listában egy elem csere
self.tipp1[i] = self.tipp2[i]
# A felhasznált elemet nullázza tipp2-ben.
self.tipp2[i] = "0"
# Eggyel több oszlop beállítás
self.column_n += 1
print('Tipposzlop', self.column_n, self.tipp1)
i += 1
def value_exchange2(self):
"""A tipp1 lista csak egy elemét változtatja meg
ciklusban. A következő elem változásához
az eredeti változás mentes tipp1 sort használja
Minden egy elem cseréje új tippsort hoz létre."""
self.column_n = 4
for index, elem in enumerate(self.tipp2):
# Ciklusonkénti mélymásolás a new_list -hez.
new_list = copy.deepcopy(self.tipp1)
# A mélymásolt lista egy elemét cseréli
if elem != '0':
new_list[index] = self.tipp2[index]
# Eggyel több oszlop beállítás
self.column_n += 1
print('Tipposzlop', self.column_n, new_list)
if __name__ == "__main__":
lista1 = ['1', '1', '1', 'x', 'x', 'x', '1', '1', '1', 'x', 'x', 'x', 'x']
lista2 = ['2', '0', 'x', '0', '0', '0', '0', '0', '0', '0', '0', '1', '2']
print('Fő oszlop 0', lista1)
app = TOTO(lista1, lista2)
app.value_exchange1()
app.value_exchange2()