0
To be more precise, yesterday I opened a question asking for help in creating a class that acted as a creator of dictionaries, and promptly I was answered, follows the class: `
class tuplas:
def __init__(self, keys, palavras):
self.keys = list(keys)
self.palavras = list(palavras)
def __getitem__(self, key):
index = self.keys.index(key)
return self.palavras[index]
def to_dict(self):
return {key: palavra for key, palavra in zip(self.keys, self.palavras)}
def __repr__(self):
return f'Tabela Completa: <{self.to_dict()}>'
What was a hand on the wheel, because I was able to advance the project well, but I came across another difficulty, I need a class that divides the dictionary that resulted from the above class into several parts, according to the information passed by the user "quantidadeP", follows the draft:
class pagina(tuplas):
def __init__(self, keys, palavras, quantidadeP):
self.quantidadeP = quantidadeP
def __getitem__(self, key):
index = self.keys.index(key)
return self.palavras[index]
def quebra(self):
What does "split into several parts" mean? What happens if the user passes
keys
as a size 10 sequence, andquantidadeP=3
?– jfaccioni