Python3 integer division

Megatron picture Megatron · Oct 22, 2013 · Viewed 150.6k times · Source

In Python3 vs Python2.6, I've noticed that I can divide two integers and get a float. How do you get the Python2.6 behaviour back? Is there a different method to get int/int = int?

Answer

Lucas Ribeiro picture Lucas Ribeiro · Oct 22, 2013

Try this:

a = 1
b = 2
int_div  = a // b