I am currently playing around with the python-jabberbot and am having trouble creating a simple method which sends a random sentence. I am not proficient in python so I am wondering where I am going wrong. I have a feeling the way I am declaring the array is my downfall:
def whatdoyouknow(self, mess, args):
"""random response"""
string[0] = 'this is a longish sentence about things'
string[1] = 'this is a longish sentence about things number 2'
string[2] = 'this is a longish sentence about things number 3'
i = random.randint(0, 2)
return string[i]
You define a list literal by putting the elements in square brackets:
Alternatively, you build the list by defining an empty list, then appending the elements:
I strongly recommend you read the Python tutorial before continuing, it explains building python types and how to manipulate them for you.