-1

I have a list that contains all positive values, and I plan to create a negative bar chart, therefore I'll need to convert all the values in this list to negative.

e.g.
donors = [324, 54, 232, 333], and I want to make it [-324, -54, -232, -333]

Chloe Y
  • 3
  • 1
  • 3

1 Answers1

0

You could use a list comprehension. In this case, it would look like:

donors = [-x for x in donors]

This will create a list with all the values in donors negated and make donors now reference this new list.

mageliz
  • 146
  • 4