Agentic AI - Agent Safety and Guardrails
This code is meant to filter AI output for banned words but causes an error:
output = "Safe text"
banned_words = ["bad", "ugly"]
for word in banned_words:
if output.index(word):
print("Banned word found")
break
What is the error and how to fix it?