Quantcast
Channel: Recent Questions - Stack Overflow
Viewing all articles
Browse latest Browse all 12111

How to calculate tax in python?

$
0
0

I need to write a function compute_tax(money_list) that calculates the total tax for a given list of financial amounts. The rich (200 money and more) pay a tax of 20. Those who are not rich, but have at least 100 money, pay a tax of 10. The others do not pay the tax. I have prepared the basis of the function, which needs to be fixed and finished.

def compute_tax(money_list):    tax = 0    for money in money_list:        if money >= 200:            tax += 20        elif money >= 100:            tax += 10        else:            tax += 0        money += tax    return taxprint(compute_tax([50, 20, 80]))print(compute_tax([50, 120, 80, 480]))print(compute_tax([250, 120, 170, 480, 30, 1000]))print(compute_tax([250, 120, 70, 4080, 30, 120, 600, 78]))

Needed output have to be:

0308080

Viewing all articles
Browse latest Browse all 12111

Trending Articles



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