Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- W = ['']
- def GetHash(algo):
- return int((str(hash(algo)))[0:3])
- def AdicionaNoDicionario(H, nome):
- tamanho = (len(H))
- cont = 0
- if tamanho == 0:
- aux = [GetHash(nome),nome]
- H.append(aux)
- return H
- for i in range(len(H)):
- if GetHash(nome) == H[i][0]:
- if type(H[i][1]) != list:
- name = H[i][1]
- H[i][1] = []
- H[i][1].append(name)
- H[i][1].append(nome)
- return H
- else:
- H[i][1].append(nome)
- return H
- aux = [GetHash(nome), nome]
- H.append(aux)
- return H
- def ProcuraNoDicionario(d, nome):
- for i in range(len(d)):
- if type(d[i][1]) == list:
- try:
- for j in range(len(d[i][1])):
- if d[i][1][j] == nome:
- print "Tem no dicionario"
- return nome
- except ValueError:
- print "Nao tem no dicionario"
- break
- else:
- if d[i][1] == nome:
- print "Tem no dicionario"
- return d[i][1]
- print "Nao tem no dicionario"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement