[Adventurer] Hashing Magic

I’ve got the same problem as @RobAnybody with the code:

# Use the hash function to find places for soldiers.
totalCells = 135

# This function hashes a string value to an integer.
def hashName(name):
    hash = 0
    for letter in name:
        hash += ord(letter)
    # The hash value should be from 0 to 134.
    # Use modulus operation to "cut" the hash value.
    hash = hash.mod(135)
    return hash

soldiers = hero.findByType("soldier")
# For each soldier say his/her name (id) and hash of it.
# The name and the number should be splitted by whitespace.
for soldier in soldiers:
    hashedName = hashName(soldier.id)
    hero.say(soldier.id + hashedName)

The error is:
Fix Your Code
Line 8: TypeError: need an object
The weird thing is that when I debug with hero.say(name) in the hashName Function it says the name of the soldier correctly.

1 Like