PHP » PYTHON |
login |
register |
about
|
function.array-randfunction.array-randimport random¶ ¶ # for num_req == 1¶ result = random.choice(input.keys())¶ ¶ # for num_req > 1¶ result = random.sample(input.keys(), num_req) import random ¶ ¶ # for num_req == 1 ¶ result = random.choice(input.keys()) ¶ ¶ # for num_req > 1 ¶ result = random.sample(input.keys(), num_req) ¶ ¶ # for arrays, replace "input.keys()" with "range(len(input))" ¶ [/code] |