I have some code in Python:
# Loading the lowercase alphabet to a list
from string import ascii_lowercase
from random import choice
attempts, alphabet, words_five, failed_words = 0, list(ascii_lowercase), "", []
while 1:
word = []
word.append(choice(alphabet))
word.append(choice(alphabet))
word.append(choice(alphabet))
word.append(choice(alphabet))
word.append(choice(alphabet))
words_one = str(word).replace(",", "")
words_two = words_one.replace("[", "")
words_three = words_two.replace("]", "")
words_four = words_three.replace("'", "")
words_five = words_four.replace(" ", "")
if words_five == "hello":
break
elif words_five not in failed_words:
attempts += 1
failed_words.append(words_five)
print(words_five)
print("Attempts: " + str(attempts))
I wanted to print different statistics, and thought a length on how long the process took would be good. However, I don't fully know how to get at this. Is this possible without using another file/script?
I was going to use the time
library to make a stopwatch, however it seems it requires its own function, hard to do when already running the main script.