Hack Forums
[Python] error in generating random comments - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [Python] error in generating random comments (/showthread.php?tid=5508728)



error in generating random comments - conardbowlings - Dec 30, 2016

Im working in a commenting bot ..
How to make it choose a different comment in each time ?
I'm noob


* - Hexi - Dec 30, 2016

Code
import random
comments = ["hello", "goodbye"]

print(random.choice(comments))



* - God - Dec 30, 2016

Code
import random
def randComment():
    comments = ["comment1", "comment2", "comment3", "comment4", "comment5"]
    randomComment = comments[random.randint(0,4)]
    return print(randomComment)
randComment()