Note that there are some explanatory texts on larger screens.

plurals
  1. POpython cricket game
    primarykey
    data
    text
    <p>I would really appreciate some help with a python program. It's a cricket program;asks user for number of overs to play then keep track of runs, wickets out and overs. That part is OK but I can't figure how to keep track of each batter and there runs.Only 1 batter can get out at one time and they swap the striker end after each over and obviously for odd runs. Please help if you can. Here is the part of the program so far I just need to add the batters.</p> <pre><code>for overs in range(1, numOvers + 1): if endGame: #.........set to true from inner loop when breaking break print() print("---------------------------") print("Enter runs for over ", overs) print("---------------------------") #inner loop for number of balls in the over for _runs in range(1, BALLS_IN_OVER + 1): #calculate the number of overs and remainding balls totalBallsFaced += 1 totalOversFaced = (totalBallsFaced // BALLS_IN_OVER) partOverFaced = (totalBallsFaced % BALLS_IN_OVER) #print() runs = int(input("&gt; ")) #...........prompt user for runs if runs &lt; 0:#.......................if negative number, add to 1 to wicket wicket += 1 print("Batter out...") if wicket &gt;= 10:#...............if batter out and if all batters out then team out print("Batters all out") endGame = 1 #..............set to true break #.......................break to outer loop else: total += runs #..................if input &gt;= 0 , add to total </code></pre> <hr> <p>Thanks for the fast feedback guys I took both ideas into consideration and finally finished. Only batter with index 1 scores and batter index 2 is the other batter, with odd runs they just swap.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload