I have this code that works well. It works in a way that I have to type a function such as soccer for the games.soccer module to be active then i can type a query such as 'latest scores', again after i close this then type autocare for this to work.. I need help in coding a way to just type the query e.g 'latest scores'..then this will iterate over all imported functions in the PLAY dictionary to find the answer.Here is the code
import games
import clauseq11
PLAY = {
'soccer': games.soccer,
'nba': games.nba,
'autorace': games.autorace,
'search_name': clauseq11.search_name,
'answer_neg1': clauseq11.answer_neg1,
}
while True:
question = input('Please enter your question: ').lower()
if not question:
break
for key, func in PLAY.items():
if key in question:
func()
break
else:
print('Sorry I do not have an answer! :(')