Note that there are some explanatory texts on larger screens.

plurals
  1. POPython - can't convert to int
    text
    copied!<p>My entire code is below (didn't want to miss anything). For some reason I keep getting an error where I can't convert a float to an int?</p> <pre><code>import math def getRange(input): if (1 &lt;= input &lt; 10): return [1,1,9] elif (10 &lt;= input &lt; 190): return [2,10,99] elif (190 &lt;= input &lt; 2890): return [3,100,999] elif (2890 &lt;= input &lt; 38890): return [4,1000,9999] elif (38890 &lt;= input &lt; 488890): return [5,10000,99999] elif (488890 &lt;= input &lt; 5888889): return [6,100000,999999] def getDigit(input): workingRange=getRange(input) multi_digit_dec = ((input-workingRange[1])/workingRange[0])+workingRange[1] multi_digit_float = math.floor((input-workingRange[1])/workingRange[0])+workingRange[1] print multi_digit_float multi_digit_int = input(multi_digit_float) decimal_remainder = multi_digit_int - multi_digit_dec ## digit_id = decimal_remainder * len(str(multi_digit_int)) ## actual_digit = str(multi_digit_dec)[digit_id] ## return actual_digit getDigit(100) </code></pre> <p>My error is:</p> <pre><code>Traceback (most recent call last): File "C:\Users\Samuel\Desktop\Python\concatenate string of variables and product values.py", line 29, in &lt;module&gt; getDigit(100) File "C:\Users\Samuel\Desktop\Python\concatenate string of variables and product values.py", line 22, in getDigit multi_digit_int = int(multi_digit_float) TypeError: 'int' object is not callable &gt;&gt;&gt; </code></pre> <p><strong>Code updated above to reflect change of variable called int to input</strong></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload