Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

pick random entry in dict python

from random import choice

dictionary[choice(list(dictionary.keys()))] # where "dictionary" is the label of, guess what, the variable holding a dictionary you want a random item from.
Comment

pick random value from dictionary python

import random
d = {'VENEZUELA':'CARACAS', 'CANADA':'OTTAWA'}
random.choice(list(d.values()))
Comment

pick random value from dictionary

country, capital = random.choice(list(d.items()))
Comment

PREVIOUS NEXT
Code Example
Python :: turn pandas entries into strings 
Python :: draw circles matplotlib 
Python :: pydrive list folders 
Python :: pytesseract pdf to text 
Python :: log scale seaborn 
Python :: discord.py send image 
Python :: seaborn pairplot set title 
Python :: df select rows based on condition 
Python :: sort python dictionary by date 
Python :: django foreign key field on delete do nothing 
Python :: triangle pygame 
Python :: scikit learn r2 score 
Python :: python print os platform 
Python :: matplotlib background color 
Python :: join two numpy 2d array 
Python :: flask development mode 
Python :: python check if list contains elements of another list 
Python :: python months between two dates 
Python :: get all file names in a folder python 
Python :: virtualenv in mac 
Python :: check package version jupyter python 
Python :: heroku change python version 
Python :: mnist fashion dataset 
Python :: how to stop the program in python 
Python :: python nCr n choose r function 
Python :: write set to txt python 
Python :: how to fill na python 
Python :: get desktop location python 
Python :: values outside range pandas 
Python :: flatten a list of list python 
ADD CONTENT
Topic
Content
Source link
Name
9+6 =