Having trouble with printing the # win message
and # lose message
, noted by comment in following code:
def guess_checker():
new_pen = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
egg_spots = [0, 3, 5, 7, 9]
turns = 3
while turns != 0:
user_guess = input("Enter a nest number to check if it has an egg: ")
if user_guess.isdigit() == False:
print("Please enter a positive, whole number to check.")
elif user_guess.isdigit() == True:
user_guess = int(user_guess)
if user_guess > len(new_pen):
print("Your pen doesn't have that many nests! Try again!")
elif user_guess in egg_spots:
print("You found an egg! You win!") # win message
break
elif user_guess not in egg_spots:
turns = turns - 1
print("That nest doesn't have an egg. Remaining guesses:", turns)
elif turns == 0:
print("You're out guesses, sorry! Better cluck next time!") # lose message
break
print("Your pen was:")
print(new_pen)
guess_checker()
I’ve simplified the function for readability. In truth, the lists new_pen
and egg_spots
are returned by another function, then passed into guess_checker()
as parameters. I was originally trying to use ascii art to display the win/loss message, but I couldn’t get that to print
either. The entire program functions as expected, except for the this strange anomaly (anomalous to me). Are my indents wrong? Thank you!