simple word guessing game python

This is a tidbit of my RabbitHole I'm making for class.

It is a flawed game, but it works.  I don't want to make it too complicated at the moment, but here is a simple word guessing game:



def word_game(self):
borders.horizon()
print("\tWord game start.....Type 'quit' to exit game.")
print("\tYou will be told when you get a correct letter.")
print("\tTo guess the whole word, type in the whole word.")
print("\tGuess my 7 letter word!")
count = 0
word = ['c','a','r','r','o','t','s']
correct = 'carrots'
correct_letters = []
play_game = True
while play_game:

guess = input("\t Your Guess = : ")
if guess == 'quit':
print("............ ok, another time ........")
exit(0)
elif guess == correct:
print("\t>>>>>> You got my Carrots! <<<<<<")
print(f" ------- number of guesses = {count} ---------")
play_game = False
elif guess in word:
correct_letters.append(guess)
print("?" * 63)
print(f"\tCorrect letters = {correct_letters}")
count += 1
elif guess not in word:
count += 1
print("\tOne letter at a time, or the whole correct word.")
print(" \t\t~~~~~~~ NOPE ~~~~~~~~")
else:
print("That will not work. Try again")

Comments

Popular posts from this blog

Statistics, Python, Making a Stem Plot

Pandas Python and a little probability

JavaScript Ascii animation with while loops and console.log