Today I worked on my guessing game. Compared to Pt 3 Friends Guessing game, I took down a large amount from the previous list and simplify to 6 names instead of 13. This way I can start simple and fix the problem. I still have not been able to make the game working. It takes a name from the list of names for the player to take a guess. The problem is that when a player guessed it right, the computer keeps showing the "out of guesses, you lost boi! It's " from the "if out_of_guesses:" statement. It will never say "you won." I am still working on fixing it. This can take a couple days to figure out before I can stay advance into having the python give character hints for each character.
#guessing name game
#!= means is not
#guessing tries += 1 every try
import random
secret_name = ['Monica','Rachel','Chandler','Joey','Phoebe','Ross']
rand_secret_name = secret_name[random.randrange(len(secret_name))]
guess = ""
guess_count = 0
guess_limit = 3
out_of_guesses = False
print("you get 2 tries!")
while guess != secret_name and not(out_of_guesses):
if guess_count < guess_limit:
guess = input("Guess the name: ")
guess_count += 1
if guess == secret_name[random.randrange(len(secret_name))]:
print("correct")
print ("Did it in", guess_count)
out_of_guesses = True
elif guess == "Monica":
print("not her, try again")
elif guess == "Rachel":
print("Ain't the spoil one")
elif guess == "Chandler":
print("Not the funny one")
elif guess == "Joey":
print("Not actor")
elif guess == "Phoebe":
print("doesn't play the guitar")
elif guess == "Ross":
print("Aint the dinosaur dude")
else:
print("someone IN friends")
else:
out_of_guesses = True
if out_of_guesses:
print("out of guesses, you lost boi! It's " )
else:
print("you won!")
https://www.youtube.com/watch?v=wmhTExlbZIE
No comments:
Post a Comment