Coders Packet

Individual and Extra's Score analysis using Python

By Sheshagiri Kulkarni

Program to show individual score and extras from a given cricket score timeline using Python

This Python program takes String input and returns a list called players_score in which individual score of players are stored. Along with the list, another variable is also returned in which extra's are stored.

Input format :



. indicates a dot ball (no runs scored off that ball)

w indicates wide

b indicates byes

W indicates Wicket

this program assumes fresh innings and considers only wide and byes as extra runs

Example :

input 1: 1..2..

first ball p1 (striker's end) scores a single hence strike is rotated and p2 (non-striker's end) comes to the striker's end and no runs scored off next 2 balls, p2 is still at the striker's end and the next ball 2 runs are scored strike remains the same, no runs scored off next 2 balls 

hence output will be


without any extras


this is all-out condition without a run hence output will be 


without any extras


Download Complete Code


No comments yet