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

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

帶有嵌套 if 語(yǔ)句的 while 循環(huán);消除多次打印并退出循環(huán)

帶有嵌套 if 語(yǔ)句的 while 循環(huán);消除多次打印并退出循環(huán)

MMTTMM 2021-08-24 19:19:53
發(fā)生的一件糟糕的事情是“搖滾”有時(shí)不會(huì)產(chǎn)生任何結(jié)果。有時(shí)我會(huì)玩游戲,它會(huì)運(yùn)行得很好,而其他時(shí)候循環(huán)會(huì)結(jié)束并且會(huì)玩零場(chǎng)比賽。如果可以的話,請(qǐng)?jiān)诔绦蛑惺褂么a,這樣我就可以了解我的錯(cuò)誤在哪里,然后我會(huì)感謝一些調(diào)整以使其有效。我認(rèn)為 while 循環(huán)中嵌套條件的順序是我正在努力解決的問(wèn)題?請(qǐng)?jiān)徴Z(yǔ)言。"""Rock, Paper, Scissors Exercise 8"""game= input("Are you ready to ply? Y or N: ").capitalize()user1 = input("What's your name? ")user2 = input("What's your name? ")p1 = input(user1 + ": Rock, Paper, Scissors? ").lower()p2 = input(user2 + ": Rock, Paper, Scissors? ").lower()p1_count=0p2_count=0games_played = 0while game == "Y":    if p1 == "rock":        if p2 == "rock":            print("It\'s a tie!")            game = input("Are you ready to ply? Y or N: ").capitalize()            p1_count += 1            p2_count += 1            games_played += 1        elif p2 == "scissors":            print(user2 + ", you got beat mothafucka!")            game = input("Are you ready to play? Y or N: ").capitalize()            p1_count += 1            games_played += 1        elif p2 == "paper":            print(user1 + ", you got beat mothafucka!")            game = input("Are you ready to play? Y or N: ").capitalize()            p2_count += 1            games_played += 1    elif p1 == "scissors":        if p2 == "scissors":            print("It\'s a tie!")            game = input("Are you ready to play? Y or N: ").capitalize()            p1_count += 1            p2_count += 1            games_played += 1        elif p2 == "paper":            print(user2 + ", you got beat mothafucka!")            game = input("Are you ready to play? Y or N: ").capitalize()            p1_count += 1            games_played += 1        elif p2 == "rock":            print(user1 + ", you got beat mothafucka!")            game = input("Are you ready to play? Y or N: ").capitalize()            p1_count += 1            games_played += 1
查看完整描述

1 回答

?
慕斯709654

TA貢獻(xiàn)1840條經(jīng)驗(yàn) 獲得超5個(gè)贊

game= input("Are you ready to ply? Y or N: ").capitalize()

user1 = input("What's your name? ")

user2 = input("What's your name? ")


p1_count=0

p2_count=0

games_played = 0


while game == "Y":

    p1 = input(user1 + ": Rock, Paper, Scissors? ").lower()

    p2 = input(user2 + ": Rock, Paper, Scissors? ").lower()

    if p1 == "rock":

        if p2 == "rock":

            print("It\'s a tie!")

            game = input("Are you ready to ply? Y or N: ").capitalize()

            p1_count += 1

            p2_count += 1

            games_played += 1

        elif p2 == "scissors":

            print(user2 + ", you got beat mothafucka!")

            game = input("Are you ready to play? Y or N: ").capitalize()

            p1_count += 1

            games_played += 1

        elif p2 == "paper":

            print(user1 + ", you got beat mothafucka!")

            game = input("Are you ready to play? Y or N: ").capitalize()

            p2_count += 1

            games_played += 1

    elif p1 == "scissors":

        if p2 == "scissors":

            print("It\'s a tie!")

            game = input("Are you ready to play? Y or N: ").capitalize()

            p1_count += 1

            p2_count += 1

            games_played += 1

        elif p2 == "paper":

            print(user2 + ", you got beat mothafucka!")

            game = input("Are you ready to play? Y or N: ").capitalize()

            p1_count += 1

            games_played += 1

        elif p2 == "rock":

            print(user1 + ", you got beat mothafucka!")

            game = input("Are you ready to play? Y or N: ").capitalize()

            p2_count += 1

            games_played += 1

    elif p1 == "paper":

        if p2 == "paper":

            print("It\'s a tie!")

            game = input("Are you ready to ply? Y or N: ").capitalize()

            p1_count += 1

            games_played += 1

        elif p2 == "rock":

            print(user2 + ", you got beat mothafucka!")

            game = input("Are you ready to ply? Y or N: ").capitalize()

            p1_count += 1

            games_played += 1

        elif p2 == "scissors":

            print(user1 + ", you got beat mothafucka!")

            game = input("Are you ready to ply? Y or N: ").capitalize()

            p2_count += 1

            games_played += 1



print("Thank you " + user1 + " and " + user2 + " for playing this classic fucking game!")

print("With " + str(games_played) + " games played, " + "the score was " + user1 + " with " + str(p1_count) + " and " + user2 + " with " + str(p2_count))

只需將這兩行 ( p1 and p2) 放入while循環(huán)中,就完成了!


這里發(fā)生的事情是,您沒(méi)有為下一次執(zhí)行while循環(huán)獲取輸入。所以值p1和p2保持不變。


所以,這現(xiàn)在可以工作了,更正了一些錯(cuò)誤..(elif第二條和第三條elif語(yǔ)句中的最后一條語(yǔ)句)


查看完整回答
反對(duì) 回復(fù) 2021-08-24
  • 1 回答
  • 0 關(guān)注
  • 297 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

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

幫助反饋 APP下載

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

公眾號(hào)

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