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

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

我收到一條錯(cuò)誤消息,說(shuō)“raw_input() 需要 1 到 2 個(gè)位置參數(shù),但給出了 4 個(gè)”

我收到一條錯(cuò)誤消息,說(shuō)“raw_input() 需要 1 到 2 個(gè)位置參數(shù),但給出了 4 個(gè)”

HUH函數(shù) 2022-06-14 10:10:49
我正在嘗試為一個(gè)簡(jiǎn)單的游戲編寫代碼。游戲的設(shè)計(jì)很好。但是我很難在原始輸入函數(shù)中包含一個(gè)變量以及文本。任何幫助,將不勝感激。這是代碼while True:    n=int(input("How many marbles to start with? ")) #Exercise 2.4    if (n>=1) and ((n%1)==0):        break    else:        print("enter a positive integer")while n>0:    p2=int(input("Player #1, there are",n, "marbles left. How many marbles will you take? "))    if (p2 not in (1,2,3)) or (p2>n):        print("not a proper input")    else:        n=n-p2        if n==0:            print("Player #1, you took the last marble and have won! ")           else:            while True:                p1=int(input("Player #2, there are",n, "marbles left. How many marbles will you take? "))                if (p1 not in (1,2,3)) or (p1>n):                    print("not a proper input")                else:                    n=n-p1                    if n==0:                        print("Player #2, you took the last marble and have won! ")                    break這是我收到的錯(cuò)誤消息TypeError                                 Traceback (most recent call last)<ipython-input-13-d507a539ca61> in <module>      6         print("enter a positive integer")      7 while n>0:----> 8     p2=int(input("Player #1, there are",(n), "marbles left. How many marbles will you take? "))      9     if (p2 not in (1,2,3)) or (p2>n):     10         print("not a proper input")TypeError: raw_input() takes from 1 to 2 positional arguments but 4 were given
查看完整描述

1 回答

?
哈士奇WWW

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

您需要將要傳遞的字符串連接input()成一個(gè)字符串,而不是像現(xiàn)在這樣將它們作為單獨(dú)的參數(shù)傳遞。代替:

input("Player #1, there are",(n), "marbles left. How many marbles will you take? ")

input("Player #1, there are " + str(n) + " marbles left. How many marbles will you take?")



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

添加回答

舉報(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)