I want to generate random ints from 4 specific numbers (1,2,5,10). I only want the output to be one of these. How?
            Asked
            
        
        
            Active
            
        
            Viewed 31 times
        
    2 Answers
1
            
            
        You can use random.choice like so:
import random
nums = [1, 2, 5, 10]
print(random.choice(nums)) # prints either 1, 2, 5, or 10
You can view more at the documentation: https://docs.python.org/3/library/random.html#random.choice
 
    
    
        Thornily
        
- 533
- 3
- 15
 
    