Q: praw reddit bot responding multiple times i am trying to make a reddit bot with praw but it responds to the same comment multiple times.
here is my code:
keyphrases = ["test","test2","test3"]

for comment in subreddit.stream.comments(skip_existing=True):
    for keyphrase in keyphrases:
        if keyphrase in comment.body:
            try:
                comment.reply("hi")
            except:
                print("to frequent")


A: Consider what happens when a comment has multiple keyphrases in it. According to this code, we'll check for the first keyphrase, then reply, then in the next iteration of the loop we'll check for the second keyphrase, and reply again, and so on.
If you only want one reply even when there are multiple keywords in the comment, you can break out of the loop when you find the first keyword match:
for keyphrase in keyphrases:
    if keyphrase in comment.body:
        try:
            comment.reply("hi")
            break
        except:
            print("too frequent")

The break keyword exits out of a loop without performing any more iterations.
