Ariana's Project

mail@pastecode.io avatar
unknown
python
a month ago
944 B
2
Indexable
Never
import random

#1a
def get_guess():
    guess = input("What word is this?: ").strip()[:5].upper()
    return guess

#1b
def print_word(word):
    print(' '.join(word))

#1c
def exact_match_compare(solution, guess):
    result = ""
    for i in range(5):
        if guess[i] == solution[i]:
            result += "🟢"
        else:
            result += "🔴"
    return result

#1d
def one_turn(solution):
    guess = get_guess()
    print_word(guess)
    match_result = exact_match_compare(solution, guess)
    print(match_result)
    
    if guess == solution:
        print("Congratulations!")
        exit()

#1e
def make_solution():
    words = ["WHICH", "THEIR", "THERE", "WOULD", "OTHER", "THESE", "ABOUT", "FIRST", "COULD", "AFTER"]
    return random.choice(words)

soln = make_solution()
one_turn(soln)
one_turn(soln)
one_turn(soln)
one_turn(soln)
one_turn(soln)
one_turn(soln)
print(f"Word was \"{soln}\", better luck next time.")