Currently I'm making a bot with OpenAI GPT-3. I'm trying to see if the responses end with ".", "!", or "?" to stop generating responses. Here's my code:
if a4.endswith(".", "!", "?"):
if int(len(a + a2 + a3 + a4)) < 50:
tc3 = a + a2 + a3 + a4
print(tc3)
raise sys.exit()
else:
tc3 = a + a2 + a3 + a4 + "."
print(tc3)
raise sys.exit()
This doesn't work and returns the error
TypeError: slice indices must be integers or None or have an index method
I'm wondering I could do without making more if statements because I want my code to look as least messy as possible so I can read the code.