Skip to content

Instantly share code, notes, and snippets.

@zakirangwala
Created September 23, 2020 14:44
Show Gist options
  • Save zakirangwala/9ea4b9159bad5b772a37a76d7b0c01c0 to your computer and use it in GitHub Desktop.
Save zakirangwala/9ea4b9159bad5b772a37a76d7b0c01c0 to your computer and use it in GitHub Desktop.
Tutorial code : Get Live Sports Scores
import sports
# Sports function
def scores(query):
try:
result = []
all_matches = sports.all_matches()
keys = list(all_matches.keys())
for j in range(len(keys)):
temp = all_matches[keys[j]]
matches = []
for i in range(len(temp)):
matches.append((str(temp[i])).lower())
for text in matches:
if query in text:
result.append(True)
print(
f'{keys[j]} : The last updated score was {text}')
speak(
f'The last updated score was {text} : {keys[j]}')
else:
result.append(False)
if True not in result:
print('Could not retrieve game scores')
speak('Could not retrieve game scores')
except Exception as e:
print('An error occurred, please try again')
speak('An error occurred, please try again')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment