-
Notifications
You must be signed in to change notification settings - Fork 0
/
standings_test.py
38 lines (27 loc) · 1.05 KB
/
standings_test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
from scrape.mlb_scraper_mlb_api import MlbScraperMlbApi
mlb = MlbScraperMlbApi()
standings = mlb.getDivisionStandings(raw_input("Enter division: "));
# Example table with garbage data
# _____________________________
# | # | Team| W | L | GB |
# |=============================|
# | 1. | STL | 90 | 100 | 1.0|
# | 2. | CHI | 100 | 10 |-10.0|
# | 3. | PIT | 3 | 5 | 2.5|
# -----------------------------
print(" _____________________________")
print("| # | Team| W | L | GB |")
print("|=============================|")
for index, team in enumerate(standings):
positionString = "|" + "{:3d}".format(index + 1) + ". |"
rowString = positionString
teamString = "{:>4s}".format(team["name"]) + " |"
rowString += teamString
winString = "{:4d}".format(team["wins"]) + " |"
rowString += winString
lossString = "{:4d}".format(team["losses"]) + " |"
rowString += lossString
gbString = "{:5.1f}".format(team["gb"])
rowString += gbString + "|"
print(rowString)
print(" -----------------------------")