0

wordlist = [['annoyed'], ['bulb'], ['fetch'], ['name'], ['noise'], ['wistful'], ['sparkle'], ['grain'], ['remind'], ['shocking'], ['productive'], ['superficial'], ['craven'], ['plate'], ['cup'], ['hat'], ['summer'], ['chilly'], ['crowd'], ['tiresome'], ['amount'], ['previous'], ['creepy'], ['insidious'], ['foolish'], ['trot'], ['well-groomed'], ['meat'], ['bottle'], ['van'], ['teeny-tiny'], ['edge'], ['knot'], ['disarm'], ['store'], ['shaggy'], ['furniture'], ['provide'], ['puzzled'], ['grubby'], ['texture'], ['cart'], ['tangy'], ['load'], ['stone'], ['plastic'], ['argument'], ['hop'], ['painstaking'], ['tense'], ['educate'], ['fearless'], ['fierce'], ['profuse'], ['addition'], ['staking'], ['attract'], ['boundary'], ['hurt'], ['delay'], ['tangible'], ['awesome'], ['ruthless'], ['guttural'], ['follow'], ['zephyr'], ['mute'], ['abandoned'], ['yak'], ['best'], ['continue'], ['stem'], ['cake'], ['multiply'], ['riddle'], ['delightful'], ['vulgar'], ['neck'], ['rampant'], ['complete'], ['certain'], ['plant'], ['organic'], ['reach'], ['tenuous'], ['chubby'], ['nut'], ['wiry'], ['knife'], ['first'], ['learned'], ['allow'], ['glass'], ['beef'], ['madly'], ['knowledgeable'], ['prepare'], ['compare'], ['perform'], ['rhetorical'], ['hover'], ['exciting'], ['adventurous'], ['cakes'], ['miniature'], ['deafening'], ['snail'], ['shy'], ['delirious'], ['hypnotic'], ['gigantic'], ['heady'], ['pen'], ['cent'], ['pump'], ['wide-eyed'], ['brief'], ['trains'], ['light'], ['order'], ['communicate'], ['bizarre'], ['flavor'], ['thirsty'], ['fasten'], ['black-and-white'], ['divergent'], ['gusty'], ['halting'], ['decide'], ['file'], ['ossified'], ['melt'], ['turkey'], ['avoid'], ['film'], ['null'], ['orange'], ['language'], ['adaptable'], ['cars'], ['eyes'], ['reject'], ['shave'], ['odd'], ['bruise'], ['cows'], ['curtain'], ['whirl'], ['wail'], ['deep'], ['mere'], ['grease'], ['phobic'], ['run'], ['scientific'], ['clear'], ['one'], ['wealthy'], ['pigs'], ['inquisitive'], ['toothsome'], ['memorise'], ['flap'], ['demonic'], ['cats'], ['injure'], ['jellyfish'], ['crow'], ['flame'], ['window'], ['rock'], ['chew'], ['pedal'], ['scared'], ['amuck'], ['hour'], ['wacky'], ['thoughtful'], ['used'], ['temporary'], ['fluttering'], ['pass'], ['ski'], ['zealous'], ['rhythm'], ['sea']]


#the word list is longer. shortened it for easier readability purposes. 

start = input("Press enter to start")
start_time = time.time()
time_limit = 10

start = input("Press enter to start")
while True:
    #timer function
    current_time = time.time()
    elapsed_time = current_time - start_time
    time_left = time_limit - elapsed_time

    #chooses a random word from list
    x = random.choice(wordlist)
    print(*x, "\n", sep = '')
    print(x)
    typed_word = input("type the word:")
    if typed_word == x:
        print("~correct~")
    else:
        print("~wrong~")

    if elapsed_time >= time_limit:
        print("time elapsed " + str(int(elapsed_time)))
        break

みなさん、こんにちは。タイピング速度をテストする新しいプロジェクトを始めたばかりですが、解決できない問題に遭遇しました。まず、下の画像の URL に示されているように、タイマーが 10 秒の制限を超えているようです。第 2 に、プレイヤーが入力した単語をプログラムで検証することができないようです。以下の画像の URL に示すように、常に ~wrong~ を出力します。リストから単語を印刷するたびに、常に [''] で印刷され、ゲームの美学が不快に見えます。それで、私は最初に問題が [''] を使用して削除したことが原因であると考えたprint(*x, "\n", sep = '') ので、別の入力を試して、 を取得できるかどうかを確認しtyped_word == xました。ただし、画像のURLに示されているように無駄に思えます。また、プログラムに print(x) を要求した理由は、リストから何が引き出されているかを正確に確認できるようにするためでした。

出力の画像:

https://ibb.co/n0KY70Y

4

1 に答える 1