OK, I have looked at many questions to do with this topic yet I couldn't find a specific answer to my queries. I am having and TypeError which has been bothering me. In my code I've been trying to hash a string very naively but my challenge is to do it without any hash libraries and with basic libraries such as 'random' or 'time' (don't know why that is useful). Here is my code so far:
import random
char_array = "Hello World!"
hash_lvl = random.getrandbits(15)
def hash (lvl, string, len_string):
a = 9
b = 2
new_array = []
for d in range(0, len_string):
new_array.extend(d)
for c in range(0, len_string):
globals()['string%s' % c] = (lvl/a)+(lvl*b)
a=a-1
b=b+1
print(char_array[0:])
if len(char_array) > 20:
print("You may not hash after 20 digits.")
elif len(char_array) < 21:
print("Hashing:")
hash(hash_lvl, char_array, len(char_array))
The for loops inside the functions have caused this so if you could get back to me I would be grateful.