Skip to content

Commit

Permalink
Done
Browse files Browse the repository at this point in the history
  • Loading branch information
sanchitaharlalka committed Apr 16, 2018
1 parent 65eefdb commit e715741
Showing 1 changed file with 25 additions and 11 deletions.
36 changes: 25 additions & 11 deletions q07_extras/build.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,28 @@
# Default Imports
from greyatomlib.python_getting_started.q01_read_data.build import read_data
data = read_data()
import yaml

# Your Solution
def extras_runs(data=data):
def read_data():
f=open('./data/ipl_match.yaml')
datadict=yaml.load(f)
return datadict

# Write your code here
def extras_runs(datadict):
deliveries=datadict['innings'][0]['1st innings']['deliveries']
extras_1=0
for delivery in deliveries:
for key,value in delivery.items():

if value['runs']['extras'] >0:
extras_1+=1

deliveries=datadict['innings'][1]['2nd innings']['deliveries']
extras_2=0
for delivery in deliveries:
for key,value in delivery.items():
if value['runs']['extras'] >0:
extras_2+=1

difference=extras_2-extras_1
return(difference)
datadict=read_data()
extras_runs(datadict)


difference =


return difference

0 comments on commit e715741

Please sign in to comment.