Hello there?
I am extremely new to python, and am trying to attend the lectures about hashing. Please cd you ceck the following code and error, and just tell me how to make it work. Please I am not that advanced user of python. I am very basic.
def create(smallest, largest):
intSet = []
for i in range(smallest, largest+1): intSet.append(None)
return intSet
def insert(intSet, e):
intSet[e] = 1
def member(intSet, e):
return intSet[e] == 1
def hashChar(c):
## (c) is a char
## function returns a different integer in the range 0-255
## for each possible value of c
return (c)
def cSetCreate():
cSet = []
for i in range(0, 255): cSet.append(None)
return cSet
def cSetInsert(cSet, e):
cSet[hashChar(e)] = 1
def cSetMember(cSet, e):
return cSet[hashChar(e)] == 1
cSetInsert(5,4)
Traceback (most recent call last):
File "<pyshell#23>", line 1, in <module>
cSetInsert(5,4)
File "C:/Users/bangash/Documents/python files/1lec10.py", line 24, in cSetInsert
cSet[hashChar(e)] = 1
TypeError: 'int' object does not support item assignment
Any help would be much appreciated.