python - Int not iterable error -


i learning python online , need submit solution, have tried code locally , on repl.it , code runs unittest of online grader throws error:

"there error/bug in code results:  internal error: runtests aborted: testoutcomeevent(handled=false, test=, result=, outcome='error', exc_info=(, typeerror("'int' object not iterable",), ), reason=none, expected=false, shortlabel=none, longlabel=none) not json serializable" 

my code below:

def calculate_tax(income2tax):     zeropercentrate = 0.0     tenpercentrate = 0.1     fifteenpercentrate = 0.15     twentypercentrate = 0.20     twenty5percentrate = 0.25     thirtypercentrate = 0.30      ten = 9000     fifteen = 10200     twenty = 10550     twenty5 = 19250      taxedincome = {}     rate = 0     name in income2tax:         if (income2tax[name] <= 1000):             rate = 0             taxedincome[name] = rate          elif (income2tax[name] >= 1001) , (income2tax[name] <= 10000):             rate = ((income2tax[name] - 1000) * tenpercentrate)              taxedincome[name] = rate          elif (income2tax[name] >= 10001) , (income2tax[name] <= 20200):             rate = (ten * tenpercentrate) + (income2tax[name] - 10000) * fifteenpercentrate             taxedincome[name] = rate          elif (income2tax[name] >= 20201) , (income2tax[name] <= 30750):             rate = (ten * tenpercentrate) + (fifteen * fifteenpercentrate) + (income2tax[name] - 20200) * twentypercentrate             taxedincome[name] = rate          elif (income2tax[name] >= 30751) , (income2tax[name] <= 50000):             rate = (ten * tenpercentrate) + (fifteen * fifteenpercentrate) + (twenty * twentypercentrate) + (income2tax[name] -30750) * twenty5percentrate             taxedincome[name] = rate          elif (income2tax[name] > 50000):             rate = (ten * tenpercentrate) + (fifteen * fifteenpercentrate) + (twenty * twentypercentrate) + (twenty5 * twenty5percentrate) + (income2tax[name] - 50000) * thirtypercentrate             taxedincome[name] = rate          return taxedincome  sampledata = {'bob': 500, 'bill': 20500, 'bale': 70000, 'bub': 8000, 'bit':19000} print calculate_tax(sampledata) 

i grateful know if there wrong code.

this 1 returns list:

ten = 9000 fifteen = 10200 twenty = 10550 twenty5 = 19250  def calculate_tax(data):     taxdata = {}     name, amount in data.iteritems():           if amount <= 1000:             taxedincome = 0          elif amount >= 1001 , amount <= 10000:             taxedincome = ((amount - 1000) * 0.1)           elif amount >= 10001 , amount <= 20200:             taxedincome = (ten * 0.1) + (amount - 10000) * 0.15          elif amount >= 20201 , amount <= 30750:             taxedincome = (ten * 0.1) + (fifteen * 0.15) + (amount - 20200) * 0.2          elif amount >= 30751 , amount <= 50000:             taxedincome = (ten * 0.1) + (fifteen * 0.15) + (twenty * 0.2) + (amount -30750) * 0.25          elif amount > 50000:             taxedincome = (ten * 0.1) + (fifteen * 0.15) + (twenty * 0.2) + (twenty5 * 0.25) + (amount - 50000) * 0.3          taxdata[name] = taxedincome       return taxdata   sampledata = {'bob': 500, 'bill': 20500, 'bale': 70000, 'bub': 8000, 'bit':19000} print calculate_tax(sampledata) 

Comments

Popular posts from this blog

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

jsf - "PropertyNotWritableException: Illegal Syntax for Set Operation" error when setting value in bean -

laravel - Undefined property: Illuminate\Pagination\LengthAwarePaginator::$id (View: F:\project\resources\views\admin\carousels\index.blade.php) -