Write a Python program to hash a word.

Write a Python program to hash a word.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
soundex=[0,1,2,3,0,1,2,0,0,2,2,4,5,5,0,1,2,6,2,3,0,1,0,2,0,2]
 
word=input("Input the word be hashed: ")
 
word=word.upper()
 
coded=word[0]
 
for a in word[1:len(word)]:
    i=65-ord(a)
    coded=coded+str(soundex[i])
print() 
print("The coded word is: "+coded)
print()

Final output

Leave a Comment