0
I have the following class:
class Buckts:
def __init__(self, keys, palavras, tamanhoP):
self.listaBuckts = dict()
self.keys = list(keys)
aux = list(zip(keys, palavras))
self.aux2 = list()
for i in range(0, len(aux), tamanhoP):
self.aux2.append(dict(aux[i:i + tamanhoP]))
That in the method below returns me a Dict (key + position of the same in aux2)
def criarB(self):
for i, pag in enumerate(self.aux2):
for v in pag.values():
self.listaBuckts[v] = i
return self.listaBuckts
The goal now would be to separate the elements of Dict from a function, all elements must be stored according to the rest of the division of its KEY by 10, ie if the key = 10 it must be stored in bucktes[0] since the rest of the division is = 0.
def indexar(self):
buckets = [[] for _ in range(10)]
for i in self.keys:
for ii in range(10):
if i % 10 == ii:
buckets[ii].append(i)
return buckets
The above method is capable of performing the task, but only when I search in the Keys list and not in the Dict list. Buckts, from this I would like to break the Dict and not just the list of Keys:
If you need any further details, please don’t hesitate to ask.
Thanks in advance!