Note that there are some explanatory texts on larger screens.

plurals
  1. POGlobal Python Lists
    text
    copied!<p>I need some help with this function I'm stuck on. </p> <p>I need to do three processes, one is to switch each player based on odd or even runs entered, which works but, I can't figure out how to replace and populate the <code>batsmanName</code> placeholder relevant to the <code>batsmanBatting</code> list and if a wicket is taken it changes to next element in the <code>batsmanName</code> list (it is added by user if a wicket is taken). </p> <p>The final process is to add scores in <code>batsmanRun</code> relevant index to the batter batting, that is, if <code>batsmanBatting[4]</code> is 'T' then <code>batsmanRun[4]</code> should accumulate according. </p> <p>I hope I've explained this clearly and makes sense, if not I could add more info, any help would be much appreciated.</p> <pre><code>def getRuns(totalScore): global batsmanName #[] empty list a function adds a player if a wicket is taken global batsmanRun #[0,0,0,0,0,0,0,0,0,0,0] #accumulators global batsmanBatting #['F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F'] global batsmanOnField #['F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F', 'F'] global wickets while(1): try: if(totalScore%2==0): print(batsmanBatting) runs=int(input("\nEnter runs for striker %s: " % batsmanName[0])) batsmanRun[0]+=runs print(batsmanRun) else: print(batsmanBatting) runs=int(input("\nEnter runs for striker %s: " % batsmanName[1])) batsmanRun[1]+=runs print(batsmanRun) if(runs&lt;7): return runs else: print("Invalid run(s) entered. Please try again.") except Exception as err: print(err) print("Please try again.") </code></pre>
 

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