Your algorithm is correct, how about something more elegant:
import random
my_list = ['A'] * 5 + ['B'] * 5 + ['C'] * 90
random.choice(my_list)
More Related Contents:
- Implement pow(x,n)%d with integers only. (without making use of library functions) [duplicate]
- Cost of len() function
- What’s a good rate limiting algorithm?
- Pick N distinct items at random from sequence of unknown length, in only one iteration
- Find all combinations of a list of numbers with a given sum
- Why is Bubble Sort implementation looping forever?
- Edit Distance in Python
- Longest increasing subsequence
- Speed of calculating powers (in python)
- heapq with custom compare predicate
- How to trace the path in a Breadth-First Search?
- Finding index of nearest point in numpy arrays of x and y coordinates
- Rotate image and crop out black borders
- General bars and stars
- Python Integer Partitioning with given k partitions
- How to invert a permutation array in numpy
- What is the complexity of the sorted() function?
- Non biased return a list of n random positive numbers (>=0) so that their sum == total_sum
- “For” loop first iteration
- Adjacency List and Adjacency Matrix in Python
- Sliding window maximum in O(n) time
- How to hash a string into 8 digits?
- Python: maximum recursion depth exceeded while calling a Python object
- NumPy grouping using itertools.groupby performance
- How do I fix wrongly nested / unclosed HTML tags?
- Python pi calculation?
- A set union find algorithm
- Finding the most frequent character in a string
- Sieve of Eratosthenes – Primes between X and N
- Heap’s algorithm permutation generator