How to generate list of random integers, but only using specified integers? (Python) -


this question has answer here:

this question generalized randomly creating list of size n, containing pre-specified integers (assuming uniform distribution). following:

perhaps syntax like

randlist([list of integers], size) 

which produce along lines of:

randlist([1,-1], 7) >>> [1,-1,1,-1,-1,-1,1] #(random) 

or

randlist([2,3,4], 10) >>> [4,3,4,2,2,4,2,3,4,3] #(random) 

i bit new python , everywhere returning range of values between low , high, , not specific values. thanks

vals = [random.choice(integers) _ in range(num_ints)] 

Comments

Popular posts from this blog

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

html - Outlook 2010 Anchor (url/address/link) -

android - How to create dynamically Fragment pager adapter -