我想根據用戶輸入分配一個數值。在Python中爲用戶輸入分配一個值
現在我想讓用戶輸入第二位的驅動程序。輸入的任何驅動程序名將被分配2分,以完成第二。除了得到3分外,與第一名相同。
程序運行前,所有可能的驅動程序名稱都設置爲0。這些都是用戶可以輸入的名字。
我不完全相信我會在Python中這樣做,並會提供幫助。
Matt_Kenseth = 0
Kyle_Busch = 0
Joey_Logano = 0
Aric_Armirola = 0
Dale_Earnhardt_Jr = 0
Denny_Hamlin = 0
Jeff_Gordon = 0
Brad_Keselowski = 0
Jimmie_Johnson = 0
Clint_Bowyer = 0
Carl_Edwards = 0
Kyle_Larson = 0
Jamie_McMurray = 0
Kevin_Harvick = 0
Kurt_Busch = 0
Ricky_Stenhouse_Jr = 0
David_Ragan = 0
Kasey_Kahne = 0
Danica_Patrick = 0
Ryan_Newman = 0
Casey_Mears = 0
Brian_Scott = 0
Trevor_Bayne = 0
AJ_Allmendinger = 0
Justin_Allgaier = 0
Paul_Menard = 0
Austin_Dillon = 0
Sam_Hornish_Jr = 0
Tony_Stewart = 0
Landon_Cassill = 0
Greg_Biffle = 0
Martin_Truex_Jr = 0
David_Gilliland = 0
JJ_Yeley = 0
Brett_Moffitt = 0
Matt_DiBenedetto = 0
Alex_Bowman = 0
Cole_Whitt = 0
Jeb_Burton = 0
Jeffrey_Earnhardt = 0
Reed_Sorenson = 0
Michael_McDowell = 0
Michael_Annett = 0
int (input ("Enter 1st Place Driver In Race.\nThis driver will receive 20 points. "))
int (input ("Enter 2nd Place Driver In Race.\nThis driver will receive 10 points. "))
int (input ("Enter 3rd Place Driver In Race.\n This driver will receive 5 points. "))
我在編程方面很新,所以很抱歉,如果我沒有太大的意義。如果用戶輸入上面列出的其中一個驅動程序(例如第一名),那麼我希望該驅動程序從0到20(第一名完成的值)。
如何將驅動程序名稱設置爲0?請用簡單的英語說明你正在嘗試做什麼。如問題所述,這是非常含糊的。 –
首先向我們展示您的嘗試。 – blackmamba
你的輸入和int調用是向後的,但是如果你運行了你輸入的內容,你就會很快知道 –