Why do I have to add the float(variable) code to have python do what it's supposed to do by default?



Before I created the division variable and used it to divide into a floating point value, my code would for some reason integer divide when I used \ 2 at the end of the parentheses in the if statement. Why is that?

Did using \ switch the default division to integer and not float for the remainder of the code?


if len(x)%2==0:
return (x[(len(x)//2)-1]+x[(len(x)//2)])/float(division)


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.