random.choice() vs random.choices()
random.choice() and random.choices() are both Python Random Module APIs, and choosing between them is a common point of confusion. This page compares their syntax, parameters, return values, and typical use cases so you can pick the right one. random.choice(): Returns a random element from a non-empty sequence. Its syntax is random.choice(seq), and it returns random element random.choices(): Returns a list of k random elements with optional weights (allows duplicates). Its syntax is random.choices(population, weights=None, *, cum_weights=None, k=1), and it returns list of k elements Example of random.choice(): random.choice(["a","b","c"]) # "b". Example of random.choices(): random.choices(["a","b"], k=3) # ["a","b","a"]. Read the full references for random.choice() and random.choices() to see parameters, edge cases, and example code side by side. Other Random Module APIs worth comparing: random.random(), random.randint(), random.sample(), random.shuffle(), random.uniform(), random.gauss(). Both belong to the Random Module category in the Python Reference documentation. Try both in the Python playground to see the behavioral difference live.