<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;"># game_while2.py
# Anne Bracy (awb93), Daisy Fan (kdf4)
# May, 2020
""" Module to play a word guessing game 
	while-loop version that checks user input
"""

import random, wordGuess

def get_user_letter():
    """Returns: a letter entered by user
    """
    user_entry= ''
    stop= False
    while not stop:
        user_entry= input("Guess a letter: ")
        stop= len(user_entry)==1 and user_entry.isalpha()

    return user_entry


# from 100 Words to Make You Sound Great by Editors of the American Heritage Dictionaries
# https://www.hmhco.com/shop/books/100-Words-to-Make-You-Sound-Great/9780618883103
word_list = ["adamant", "affectation", "affinity", "allay", "amelioration", "amenable", "amoral", "assuage", "bauble", "beguile", "beset", "bulwark", "busybody", "complacent", "concomitant", "consign", "contend", "cosmopolitan", "culpable", "depravity", "derelict", "dissimulate", "dissipate", "distill", "dogmatic", "elicit", "epithet", "espouse", "expediency", "forestall", "furtive", "galling", "gloat", "gratuitous", "hallmark", "happenstance", "ignominious", "imperturbable", "ingratiate", "innocuous", "intemperate", "interpolate", "inure", "jingoism", "juggernaut", "ken ", "latent", "legacy", "ludicrous", "mandate", "maven", "mawkish", "modus operandi", "nefarious", "nicety", "nonchalance", "obdurate", "orthodoxy", "palliate", "patina", "penury", "pernicious", "perpetuate", "pittance", "pompous", "precipitate", "prescience", "profusion", "propensity", "pugnacity", "pusillanimous", "quip", "rankle", "reconciliation", "resiliency", "respite", "riposte", "sacrosanct", "scapegoat", "spurious", "squander", "supersede", "surreptitious", "tenacity", "tenuous", "travail", "truculence", "turpitude", "tyro", "unbridled", "uncanny", "urbane", "velleity", "venial", "verbose", "vexation", "vista", "wanton", "wheedle", "yammer"]

N_CHANCES = 10
print('You have '+str(N_CHANCES)+ ' chances to guess the secret word ...')
secret = wordGuess.SecretWord(random.choice(word_list))

# User guesses until secret is solved or out of guesses
n_guesses= 0
while not secret.is_solved() and n_guesses&lt;N_CHANCES:
    secret.print_word_so_far()
    user_guess= get_user_letter()
    secret.apply_guess(user_guess)
    n_guesses  += 1

# Loop ended. Which outcome?
if secret.is_solved():
    print("Awesome! You got it!")
else:
    print("Sorry you are out of chances.")
secret.reveal()
</pre></body></html>