class Node:
def __init__(self, name, phone, address, next):
self._name = name
self._phone = phone
self._address = address
self._next = next
def __str__(self):
return "("+self._name+","+self._phone+","+self._address+")"
class ContactsHT:
MAXSIZE = 100
# hash table for contacts
def __init__(self):
self._hashtable = [Node("","","",None)]*ContactsHT.MAXSIZE
self._size = 0
@classmethod
def myhash(cls,name):
sum = 0
for x in name:
sum = sum + ord(x)
return sum%MAXSIZE
def find(self,name):
hindex = ContactsHT.myhash(name)
p = self._hashtable[hindex]
found = False
while p._next != None and not found:
if name == p._next._name:
found = True
else:
p = p._next
if found:
return (p._next._name,p._next._phone,p._next._address)
else:
return None
def insert(self,contact):
def delete(self,name):
def update(self,contact):
def size(self):
return self._size
def __str__(self):
result = "\n"
for hindex in range(MAXSIZE):
p = self._hashtable[hindex]
while p._next != None:
result = result + str(p._next)+"\n"
p = p._next
return result+"\n"
[5]*10
s = "John:111-2222:123 Main Street"
c = s.split(":")
print(c)