Quantcast
Channel: Active questions tagged python - Stack Overflow
Viewing all articles
Browse latest Browse all 23305

Trying to subtract a number by numbers in a list in python

$
0
0

I have a list (with decimals) and a variable (with decimals). I want that variable to decrease by every number in that list combined.

EXAMPLE:

list = [0.9, 1.1, 1.2, 0.8]a = 5a -= list[0:len(list]a SHOULD equal 1 but I keep getting an error

EXAMPLE2:

Four people work at a job and they each have different paychecks (list), the boss wants to know how much money he gets so we wants to deduct the profit (a) by each of the workers paychecks combined.

So how could that be translated into code?

The error:TypeError: unsupported operand type(s) for -=: 'int' and 'list'


Viewing all articles
Browse latest Browse all 23305

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>