第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

為什么我的函數(shù)返回錯誤消息:'wordlist is not defined

為什么我的函數(shù)返回錯誤消息:'wordlist is not defined

達令說 2021-06-23 17:01:08
運行此程序時,我收到此錯誤消息:NameError: name 'wordList' is not defined。想不通為什么。謝謝。隨機導(dǎo)入定義主():def getRandomWord(wordList):    wordIndex = random.randint(0, len(wordList) -1)    return wordList[wordIndex]words = "Harry John Paul Jane Sue Frank Julie Tom Alice Sam".split()secretWord = getRandomWord(words)print("Welcome to You Bet Your Life with Groucho\n")print("Say the secret word and win a thousand dollars!")your_word = input("What is your guess for the secret word? ")if your_word == secretWord:    print("Congratulations you are correct. The secrt word is", secretWord)    print("and you win $1000 dollars !")else:    print("Sorry, that is not the secret word.")playAgain = TruewordList = secretWordplayAgain = input("Do you want to play again? (yes or y) to continue")if playAgain == "Yes" or playAgain == "y":    getRandomWord(wordList)else:    print("Ok. Goodbye.")如果名稱== ' main ': main()
查看完整描述

1 回答

?
RISEBY

TA貢獻1856條經(jīng)驗 獲得超5個贊

我看到你在重新開始游戲時遇到了麻煩。簡單地調(diào)用您的函數(shù)不會重新啟動整個游戲或?qū)⒛鷰Щ仨敳?,但您可以進行的一個小調(diào)整是將所有內(nèi)容放入while具有這樣條件的循環(huán)中


play = 'y'

while play == 'y':


    words = "Harry John Paul Jane Sue Frank Julie Tom Alice Sam".split()

    ....


    playAgain = input("Do you want to play again? (yes or y) to continue")


    if playAgain == "Yes" or playAgain == "y":

        play = 'y'

        continue

    else:

        print("Ok. Goodbye.")

        play = 'n'

所有這一切都是,如果play的值為 ,則y游戲?qū)⒅夭?,直到值更改?,n然后循環(huán)將結(jié)束,因此游戲


查看完整回答
反對 回復(fù) 2021-06-29
  • 1 回答
  • 0 關(guān)注
  • 404 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號