I'm trying to do a switch (per say) of commands.
if 'Who' in line.split()[:3]:
Who(line)
elif 'Where' in line.split()[:3]:
Where(line)
elif 'What' in line.split()[:3]:
What(line)
elif 'When' in line.split()[:3]:
When(line)
elif 'How' in line.split()[:3]:
How(line)
elif "Make" in line.split()[:3]:
Make(line)
elif "Can You" in line.split()[:3]:
CY(line)
else:
print("OK")
So the explanation. If Who, whatWhat...etc are in the first 3 words of the command then it executes the corresponding function. I just want to know if there is a smarter way to do this other than a lot of if,elif and else?
Aucun commentaire:
Enregistrer un commentaire