I am essentially trying to work out if a specified index is a list or not. I have a list embedded into an index.
This is what I have so far
if len(hashTable[hashed-1])>1: hashTable[hashed-1].append(inVal) else: tempTable = [hashTable[hashed-1], inVal] hashTable[hashed-1] = tempTable print(inVal,hashed) print(hashTable) The output of the list is: (the 0's an 10 are irrelevant)
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, [1, 3], 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 10] The error is:
if len(hashTable[hashed-1])>1: TypeError: object of type 'int' has no len()
hashTable[hashed-1]is an int, not a list, hence the error, tryif isinstance(hashTable[hashed-1], list) and len(hashTable[hashed-1]) > 1