I'm creating a project where the person is supposed to respond and this randomizer is supposed to send a random response that would either be in the category of yes and no.
            Asked
            
        
        
            Active
            
        
            Viewed 123 times
        
    -2
            
            
        - 
                    2Put the words in a list, then pick a random element of the list with `random.choice()`. – Barmar Oct 08 '19 at 01:10
- 
                    @Barmar I did what you told me to do but then I got this error message: Traceback (most recent call last): File "project3.py", line 12, infrom classref3 import Dog File "/Users/sergioley-languren/Documents/itt/independent_projects/classref3.py", line 3, in – Sergio Ley Oct 08 '19 at 01:26class Dog: File "/Users/sergioley-languren/Documents/itt/independent_projects/classref3.py", line 43, in Dog import random File "/Users/sergioley-languren/Documents/itt/independent_projects/random.py", line 3, in integers 
- 
                    @DawnChopin Don't name your _own_ file as random.py because that will hide the _true_ random module. – Gino Mempin Oct 08 '19 at 02:46
- 
                    I reverted back to the original question. **If you have a new question, ask a new, separate question**. When you [completely changed the post](https://stackoverflow.com/revisions/58278961/2), the [existing answer](https://stackoverflow.com/a/58279062/2745495) and the comments do not all make sense anymore. Also, the original post was already closed and marked as a duplicate, making it unlikely someone else will notice it. Ask a new question if you have new problems. – Gino Mempin Oct 08 '19 at 02:50
1 Answers
0
            
            
        You can use random.choice to select a random element from a list of strings.
import random
allResponses = ['yes', 'no', 'maybe', 'so']
randomResponse = random.choice(responses)
See random.choice documentation
 
    
    
        Melanie Kneisel
        
- 74
- 4
- 
                    
- 
                    
- 
                    File "classref3.py", line 3, inclass Dog: File "classref3.py", line 43, in Dog import random File "/Users/sergioley-languren/Documents/itt/independent_projects/random.py", line 3, in – Sergio Ley Oct 08 '19 at 01:47integers TypeError: 'module' object is not callable This the Error I got from this 
- 
                    @DawnChopin Don't name your _own_ file as random.py because that will hide the _true_ random module. – Gino Mempin Oct 08 '19 at 02:46
 
    