Expected and continuous

From Computational Statistics (CSE383M and CS395T)
Jump to navigation Jump to search

The question posted in Parsing text files

f = open('./data/first_10000_games.pgn', 'r')
white = 0
black = 0
draw = 0
for line in f:
    if 'Result' in line:
        loc = line.find('-')
        if line[loc-1] == '0':
            black +=1
        elif line[loc+1] == '0':
            white += 1
        else:
            draw +=1
print white, black, draw