Programmeerimine

eduka projekti kirjeldus

import random as r

words_hard = [
    "table", "star", "root", "flat", "turtle", "fish", "goat", "rocket",
    "dragon", "power", "source", "program", "wheel", "candle", "dog", "cat", "branch"
]

words_easy = [
    "dragonborn", "monosaccharide", "disposable", "environment",
    "implementation", "disorientation", "carbohydrate", "disrespectful", "dominant"
]

difficulty = input("Please select difficulty('h' for 'hard' and 'e' for 'easy'): ")

if difficulty == 'h':
    words = words_hard
elif difficulty == 'e':
    words = words_easy
else:
    raise ValueError("Not allowed input")

word = r.choice(words)
guesses = len(word)
guess_word = ["*"] * len(word)

while True:
    print(f"\nGuesses left: {guesses}")
    print(f"The word is: {''.join(guess_word)}")