Royals Scorecard

Last Updated:
Royals logo
HoleWinsLossesScore+25
13446+10(-2)
103051+25(E)
Avg3249+45

Analysis

Here is the code in Python to parse and print the statistics of the Kansas City Royals baseball team from 1990 to 2001:

import re

def parse_stat(line):
    match = re.match(r"(\d+)\s+([A-Za-z]+)\s+(\d+)", line)
    if match:
        wins, losses, games_played = match.groups()
        return {
            'wins': int(wins),
            'losses': int(losses),
            'games_played': int(games_played)
        }
    else:
        return None

stat_dict = {}

for line in data.split('\n'):
    if line:  # skip empty lines
        stats = parse_stat(line)
        if stats:
            stat_dict[stats['wins']] = {
                'wins': stats['wins'],
                'losses': stats['losses'],
                'games_played': stats['games_played']
            }

for year, stats in stat_dict.items():
    print(f"{year}: {stats['wins']} wins, {stats['losses']} losses, {stats['games_played']} games played")

This code uses regular expressions to parse the lines of data. It assumes that each line has the format "X wins, Y losses, Z games played", where X is the number of wins, Y is the number of losses, and Z is the number of games played.

The parse_stat function takes a line of data as input and returns a dictionary containing the parsed statistics. The stat_dict variable stores all the parsed statistics in a nested dictionary structure.

Finally, the code prints out the statistics for each year.

Note: This code assumes that the data is stored in a string variable called data. You should replace this with your actual data source. Updated: June 4, 2025 at 4:56 AM