O'Reilly logo
  • Shen Zhu thinks this is interesting:

    total = sum(numbers)
    result = []
    for value in numbers:
        percent = 100 * value / total
        result.append(percent)

From

Cover of Effective Python: 59 Specific Ways to Write Better Python

Note

Iterate over generator twice, that's why it does not work at first