fh1
Active Coder
hello! for some reason on line 16 and 29, it says “pickanimword cant be defined.” I’ve done basically everything and even asked chatgpt and copilot (didn’t help lol) heres the code:
Python:
guesses = 3
import random
cater = input("Choose a catergory: Animals, Plants, Food\n")
animword = ["Cat", "Dog", "Coyote", "Snake", "Fish", "Lion"]
if cater.lower() == "Animals":
pickanimword = random.choice(animword).lower()
pickanimword = pickanimword.lower()
lenanimword = len(pickanimword)
print("You have 3 guesses.")
print("The word has")
print(lenanimword)
print("Letters")
while True:
guess = input("Put your guesses! Press H for a hint\n").lower()
if guess == "H":
if pickanimword == "Cat":
print("Word starts with a C!")
elif pickanimword == "Dog":
print("Word Starts the a D")
elif pickanimword == "Coyote":
print("Word starts with a C and a O")
elif pickanimword == "Snake":
print("Word starts with an S")
elif pickanimword == "Fish":
print("Word starts with an F")
elif pickanimword == "Lion":
print("word starts with L")
continue
if guess != pickanimword:
guesses -= 1
print(f"Wrong! You have {guesses} guesses")
if guesses == 0:
print("You have no more guesses! game over.")
quit()
elif guess == pickanimword:
print("correct!")
break