I am working on a small python application and found this piece of code in the Python 3.4 random documentation: https://docs.python.org/3/library/random.html?highlight=random#module-random
weighted_choices = [('Red', 3), ('Blue', 2), ('Yellow', 1), ('Green', 4)]
population = [val for val, cnt in weighted_choices for i in range(cnt)]
random.choice(population)
It works perfectly; however, I don't fully understand what's going on in the second line.
I'm asking solely because I want to broaden my understanding of Python.