0

NBA Stats

I'm trying to build a program that takes the stats of the NBA from the data.nba.net site and print out the stats. But, I keep getting an unassigned error, I'm still only mid-level, at best, at this and am just stuck. Any ideas? here is my code: from requests import get from pprint import PrettyPrinter Base_url = "https://data.nba.net" all_json = "/prod/v1/today.json" printer = PrettyPrinter() def get_links(): data = get(Base_url + all_json).json() links = data['links'] return links def get_Scoreboard(): scoreboard = get_links()['currentScoreboard'] games = get(Base_url + scoreboard).json()['games'] for game in games: home_team = game['hTeam'] away_team game['vTeam'] clock = game['clock'] period = game['period'] print("----------------------------------------") print(f"{home_team['triCode']} vs {away_team[triCode]},{clock}, {period}") get.scoreboard()

12th Sep 2022, 2:23 AM
Kevin Calderon
Kevin Calderon - avatar
3 Réponses
+ 3
The for...in loop is *probably* suppposed to be inside get_Scoreboard() - otherwise, <games> is something undefined. You also have a typo in calling get_Scoreboard() - you wrote get.scoreboard() Better save the code as a code bit and share its link ... https://www.sololearn.com/post/75089/?ref=app If you share a code bit link, there will be more room in post Decription to include the error Description - as Slick had suggested ...
12th Sep 2022, 11:06 AM
Ipang
+ 2
What is the error code you get? Post it, all of it.
12th Sep 2022, 9:04 AM
Slick
Slick - avatar
+ 2
@Slick this is my error no matter what I seem to change: Traceback (most recent call last): File "C:\Users\calde\PycharmProjects\NBAstats\main.py", line 21, in <module> for game in games: NameError: name 'games' is not defined
12th Sep 2022, 11:57 AM
Kevin Calderon
Kevin Calderon - avatar