-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
65eefdb
commit e715741
Showing
1 changed file
with
25 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |