How should I improve this?-Python
This is basically a chat bot program which lets you talk to Star Wars Characters!!! It’s in progress and I might submit it into the AI competition!!! But since I’m learning Python at a pretty slow pace, mainly because of COVID. I need help. My main question about this program is “When you are chatting with the Chat Bots in this program, How do I program it so that you can ask more than 1 question and don’t have to like press Run again to ask another one?”
You can clean up your code a lot by using dictionaries: https://docs.python.org/3/tutorial/datastructures.html#dictionaries
You can do something like this
Notice how I used
.get() instead of indexing. This enables a default response instead of throwing an error.
Also notice how it is in a
while True loop so it will repeatedly ask for input.