Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

random element python

import random

list = ("Carrots","Peanuts","Apples","Peaches")

random.choice(list)
# return a random element from the list
random.choice(list,2)
# return 2 random elements from the list
Comment

PREVIOUS NEXT
Code Example
Python :: python for each attribute in object 
Python :: default requires 2 arguments, 1 provided 
Python :: goal parser 
Python :: django run queryset in terminal 
Python :: check all python versions ubuntu 
Python :: table python 
Python :: python head function show all columns 
Python :: update python in cmd 
Python :: np random array 
Python :: ImportError: cannot import name ABC 
Python :: django get current date 
Python :: how to add headings to data in pandas 
Python :: tribonacci sequence python 
Python :: pandas drop columns by index 
Python :: python get time difference in milliseconds 
Python :: python añadir elementos a una lista 
Python :: how to print dataframe in python without index 
Python :: how to change the rate of speech in pyttsx3 
Python :: add jupyter environment 
Python :: how to add contents of one dict to another in python 
Python :: how to download a file in python using idm 
Python :: python list flatten 
Python :: python find closest value in list to zero 
Python :: open csv file in python 
Python :: decode base64 with python 
Python :: convert array to dataframe python 
Python :: how to find columns of a dataframe 
Python :: how to split string with comma in python 
Python :: pandas unnamed zero 
Python :: parcourir une liste par la fin python 
ADD CONTENT
Topic
Content
Source link
Name
6+8 =