Created
September 23, 2020 14:44
-
-
Save zakirangwala/9ea4b9159bad5b772a37a76d7b0c01c0 to your computer and use it in GitHub Desktop.
Tutorial code : Get Live Sports Scores
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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