Answer:
This should be right
Step-by-step explanation:
import random
import time
def word_counts():
def time_convert(sec):
mins = sec // 60
sec = sec % 60
hours = mins // 60
mins = mins % 60
print("Time Lapsed = {0}:{1}:{2}".format(int(hours),int(mins),sec))
words = []
word = input("Please enter a starting word: ")
print("The monkey is looking for your word...")
words.append(word)
start_time = time.time()
final_word = []
def find_word():
dict = {1:'a',2:'b',3:'c',4:'d',5:'e',6:'f',7:'g',8:'h',9:'i',10:'j',11:'k',12:'l',13:'m',14:'n',15:'o',16:'p',17:'q',18:'r',
19:'s',20:'t',21:'u',22:'v',23:'w',24:'x',25:'y',26:'z',27:' '}
word = []
count = 0
while count < (len(words[0])):
num = random.randint(1,27)
word.append(dict[num])
if word[0] == words[0]:
final_word.append(words[0])
count = count+1
check = ''.join(word)
return check
word_counter = 0
z = ''
numb = 0
while numb < 1:
if word_counter > 1000000:
print("Your word was to hard the monkey killed himself")
return
if z == words[0]:
print("YAY!! the monkey found your word it took " + str(word_counter) + " cycles to find "+ str(words[0]))
numb = numb+1
end_time = time.time()
time_lapsed = end_time - start_time
(time_convert(time_lapsed))
else:
word_counter = word_counter + 1
z = find_word()
x = 0
while x < 1:
word_counts()