1
は週1 player1のために例えば ポイントを獲得43 player2 26 player3 38などなどループ/ネステッド・ループの問題はPython 2.7
その後現在、このプログラムは、最初の選手が得点、再度だけ、すべての5人のプレーヤーへの質問を表示しますもう一度選手質問をし、週2
ために同じことを行います2番目の選手のスコアを表示すると、これは5回繰り返され、選手だけが反復します。
はどこが間違っているつもりです、任意のヘルプは非常にあなたは少し別の関数を使って、どのようにあなたのコール情報を変更する場合、私が思うよう
playerList=[]
def Playeradd():
playerList.append(item)
def Playercreate():
global item
item = raw_input("Enter Player name: ")
Playeradd()
[Playercreate()for _ in range (5)]
print "You have selected", len(playerList), "players for your squad, Your selected squad is.."
for item in playerList:
print item
player =Playercreate
scorecheck=[]
x=0
totalscore=0
def pointsaward():
global scorecheck, totalscore
y=1
player=y
x=0
while x < 5:
print "Please enter score for ", playerList[x]
for player in playerList:
print "Did "+player+" play in the game?"
play = raw_input(" Did he play the match (yes or no?) ")
if play == "yes":
play1=2
goalS= int(raw_input(" Did he score, if so how many?"))
goalS=goalS*5
goalA= int(raw_input(" How many assists?"))
goalA=goalA*3
motm= raw_input(" Did he win man of the match (yes or no?) ")
if motm == "yes":
motm1=5
else:
motm1=0
yelC=raw_input(" Did he recieve a yellow card (yes or no?) ")
if yelC == "yes":
yelC1= -1
else:
yelC1=0
redC=raw_input(" Did he recieve a red card (yes or no?) ")
if redC == "yes":
redC1= -5
else:
redC1=0
PenM=raw_input(" Did he miss a peno(yes or no?) ")
if PenM == "yes":
PenM1= -3
else:
PenM1=0
else:
play1=0
print player+" did not play"
playerpoint1= play1+goalS+goalA+yelC1+redC1+PenM1
PlayerandScore= [playerList[x],playerpoint1,]
scorecheck.append(PlayerandScore)
totalscore+= playerpoint1
x+= 1
y+= 1
print "This player has scored a total of ", PlayerandScore, " this week "
pointsaward()
これはうまくいく、私はまだpyhonに新しいので、私は辞書について学ぶ必要があります。私は2週間目にもう一度質問をしてもらうつもりですが、空のリストを続けて印刷しています。 – Grimble6
2週間目に質問する方法がわかります。別の質問をすることもできます。そして、辞書、リスト、タプルでできることはたくさんあります。状況に最も適したものが何であるかを把握するだけです。あなたは '{}: ''' ' –
のような不要な文字をすべて捨てるように情報を印刷する方法を書式設定することもできます。同じ質問をもう一度聞いて、1週間目の総合スコア2つの – Grimble6